I Computer a Life-long Learner

Python3 读取中文输出乱码解决

2018-02-24

Python3 读取中文输出乱码解决

解决方法

读取时设置 encoding

with open('test.txt', encoding='utf-8') as f:
  lines = f.readlines()
  for line in lines:
    print(line)

Similar Posts

Comments(需要科学上网)