0
点赞
收藏
分享

微信扫一扫

python3 TypeError: 'map' object is not subscriptable

陆公子521 2022-10-13 阅读 167


add “list” to map,eg:

return list(map(apply_filters_to_token, sentences))

eg2:

In Python 3 map returns a generator. Try creating a list from it first.

with open("/bin/ls", "rb") as fin: #rb as text file and location
buf = fin.read()
bytes = list(map(ord, buf))
print (bytes[:10])
saveFile = open('exampleFile.txt', 'w')
saveFile.write(bytes)
saveFile.close()


举报

相关推荐

‘int‘ object is not subscriptable

0 条评论