【发布时间】:2015-11-11 08:07:21
【问题描述】:
for line in fo:
line = " ".join(line.split())
line = line.strip()
我收到一个错误
line = ''.join(line.split())
TypeError: sequence item 0: expected str instance, bytes found
它在 python 2.x 中运行良好,但在 3.4 中无法运行 请为此提出适当的解决方案
【问题讨论】:
-
将字节转换为 str,可能会有所帮助。
-
fo = open("input.txt", "rb")
标签: python string python-3.x byte typeerror