两种解决方法

s = '\u60a8\u63d0\u4f9b\u7684\u5e10\u53f7\u4e0d\u6b63\u786e'  # 您提供的帐号不正确
print(f'"{s}"')
print(f"'{s}'")

结果:

"您提供的帐号不正确"
'您提供的帐号不正确'

 

 

PS:python3 将字符串unicode转换为中文 

记录一个经常会遇到的问题:

网页请求结果中得到的文本打印出来是“\uxxxx”的字符串格式,在python3中使用text.decode('unicode_escape')会报错:‘str' object has no attribute 'decode'

正确的姿势是:

text.encode('utf-8').decode("unicode_escape")

 

相关文章:

  • 2022-12-23
  • 2021-10-16
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-02-02
  • 2021-07-02
相关资源
相似解决方案