![图片[1]-python列表中可以用中文字吗?-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5ec5f79c58acb557.jpg)
python列表中可以使用中文,在我们使用中文时可以在程序第一行添加#encoding=utf-8来防止乱码,或在输出时对列表进行转码。
#encoding=utf-8
importjson
list_words=['你','我','他']
print(list_words)
print(str(list_words).decode('string_escape'))#正常显示汉字(可靠性不高,原因尚不明确)
list_words_result=json.dumps(list_words,encoding='UTF-8',ensure_ascii=False)#正常显示汉字(经实验可靠性较高)
print(list_words_result)原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END

















































暂无评论内容