python打印列表有中文乱码怎么解决?

图片[1]-python打印列表有中文乱码怎么解决?-uusu优素-乐高,模型,3d打印,编程

定义列表并直接输出,结果输出结果中文是乱码:

e=['你好',1,'apple']
printe

输出结果:

['\xe4\xbd\xa0\xe5\xa5\xbd', 1, 'apple']

解决方法:

e=['你好',1,'apple']
printjson.dumps(e,encoding='utf-8',ensure_ascii=False)

输出结果:

["你好", 1, "apple"]

原文来自:https://www.py.cn
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容