with open(path) as f:
for line in f:
print line
path
是单行文件\xc2
当我运行它时,我得到
\xc2
现在让我们改变这个
with open(path) as f:
for line in f:
var = '\xc2'
print var
当我运行它时,我看到
UnicodeDecodeError: 'ascii', '\xc2d', 0, 1, 'ordinal not in range(128)'
然后我尝试比较所以我做
with open(path) as f:
for line in f:
line = line.strip()
line1 = '\xc2d'
# print line1
print line == line1
我看到了False
这里发生了什么?