rlist = []
rlist.append(a).append(b)
print(rlist)
返回标题中的错误:AttributeError: 'NoneType' object has no attribute 'append'
这时可以type一下rlist发现已经变成了NoneType
原因:append会修改rlist本身,并且返回None
修改如下:
rlist = []
rlist.append(a)
rlist.append(b)
print(rlist)
输出[a,b]