search

Home  >  Q&A  >  body text

如何用python把这段ASCII码转换为可读的字符串

查找了ord和chr这类,没有搞定。想用python把"\u5b57\u7b26\u7f16\u7801"转为汉字字符串。

PHP中文网PHP中文网2805 days ago1117

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 17:35:50

    print string.encode('utf8')

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:35:50

    This is Unicode

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:35:50

    The answer is as follows:

    #!/usr/bin/env python3
    # -*- coding:utf-8 -*-
    str = "\u53ef\u8f6c\u51fa\u91d1\u989d\u8d85\u9650"
    str.encode('utf8')
    print(str)

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:35:50

    This is unicode, you need u"u5b57u7b26u7f16u7801", print is Chinese, character encoding

    reply
    0
  • Cancelreply