You can not concatenate list with string.
In your code line
is list
and you are trying to concatenate it with '
'
a str
. I don't know what You are trying to acomplish here but for your code to work you can do something like outfile.write('f{line}
')
.
I would recommend using built-in json
module instead. Json works best with list
or dict
containg str
data.
import json
with open('text3','w') as outfile:
json.dump(inputList, outfile)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…