Home  >  Q&A  >  body text

python - pycharm中中文列表输出\xe5\xb0\x8f之类的怎么解决

#coding=utf-8
member=["小","大","小"]
print(member)

print("小打小闹")

结果为:
['\xe5\xb0\x8f', '\xe5\xa4\xa7', '\xe5\xb0\x8f']
小打小闹

问:怎么解决列表输出的编码问题

巴扎黑巴扎黑2742 days ago988

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-04-17 17:31:06

    print str(member).decode('string_escape')

    can be solved

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:31:06

    When outputting a list, the elements inside are processed according to %r (call __repr__()). When outputting str, they are processed according to %s (call __str__()). So, if you want to see Chinese in the list, just:

    for i in member:
        print i

    reply
    0
  • Cancelreply