标签:题解 title 赋值 print none 解决 ash split mda
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()
把lt= lt.append(word)改为lt.append(word)后问题解决。
原因:append会修改a本身,并且返回None。不能把返回值再赋值给a。
Python问题——AttributeError: 'NoneType' object has no attribute 'append'
标签:题解 title 赋值 print none 解决 ash split mda
原文地址:https://www.cnblogs.com/oycc2000/p/11279677.html