python提示AttributeError: 'NoneType' object has no attribute 'append'
Python问题——AttributeError: 'NoneType' object has no attribute 'append'
f=open("data.csv")
for line in f:
line = line.strip("\n")
ls = line.split(",")
lt=[]
for word in ls:
word=word.strip()
lt=lt.append(word)
print(",".join(lt))
f.close()
After the problem is solved lt = lt.append (word) to lt.append (word).
The reason: append itself will be a modification, and returns None. The return value can not be re-assigned to a.