代码:
ff = open(outfile, 'rw').read().replace('\n','')
for n in list(eval(ff)):
c = []
c.append(n)
print c
文件输出:
((592, (1, '\xd0\x94\xd0\xbe\xd0\xb3\xd1\x81\xd1\x8f.', 0), (2, '\xd0\xa3\xd1\x81\xd0\xbe\xd1\x80\xd0\xbe\xd0\xbc.', 0),
...
但我想看字母,而不是编码。我
使用 .decode()
不同的编解码器,但只改变了编码,没有得到字母
最佳答案
我猜你正试图用 python 读取一个文件并逐行打印它。你可以使用这个片段:
import sys
outfile = 'file path'
with open(outfile, 'r') as f:
lines = f.readlines()
for line in lines:
sys.stdout.write(line)
关于python - 将python编解码器转换为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29035017/