Python open函数打开中文为乱码,英文是正常的。具体见下图。捉急,谢谢各位大侠!!

如题所述

1、你要贴test.py的代码出来呀

2、我这边按你的思路写了一个,没什么问题啊:

fname='zhongwen.txt'
with open(fname) as f:
s=f.read()
print s

$ python print_chinese.py

hi

hello

百度

追问

你好,test.py代码如下:
#coding=utf-8
text=open('keyword.py').read()
print text

追答

要养成用with open的习惯啊,你改成为那样的,运行看看咯

温馨提示:答案为网友推荐,仅供参考
相似回答