0
我目前正在将此作为一段I/O流的代码运行 - 我收到以下错误TypeError:'map'对象不是可下载的打印(bytest [:10])。在Python 3中运行它的正确方式是什么?Python 3 - TypeError:'map'对象不是可订阅的
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()
你可以使用[**'itertools.islice' **](https://开头的文档。 python.org/3/library/itertools.html#itertools.islice) –
@PeterWood是的,如果你只需要读一个特定的片,那可能会更好。 – jdehesa