【发布时间】:2017-05-08 12:12:38
【问题描述】:
我目前正在将此作为 i/o 流的一段代码运行 - 我收到以下错误 TypeError: 'map' object is not subscriptable for the print (bytest[:10])。在 Python 3 中运行它的正确方法是什么?
with open("/bin/ls", "rb") as fin: #rb as text file and location
buf = fin.read()
bytes = map(ord, buf)
print (bytes[:10])
saveFile = open('exampleFile.txt', 'w')
saveFile.write(bytes)
saveFile.close()
【问题讨论】:
标签: python