python3 TypeError: 'map'オブジェクトは添え字化できません



Python3 Typeerror Mapobject Is Not Subscriptable



マップに「リスト」を追加します。例:

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()