append()方法是不是不能向列表里面添加字符串?
a = []>>> b = '123456789'
>>> a = a.append(b)
>>> a
>>> print(a)
None
为啥我向一个列表里用append添加一个字符串添加不进去
返回None
a明明是一个列表,但为什么传不仅去数据
求大佬解答! Orz 本帖最后由 suchocolate 于 2021-3-28 10:24 编辑
a.append(b)就行,不用再赋值给a。
f1帮助文档:只是在末尾增加一个元素,并不会返回一个新的list。
list.append(x)
Add an item to the end of the list. Equivalent to a = .
>>> a = a.append(b)
因为append返回值是None
你对a重新赋值了 suchocolate 发表于 2021-3-28 10:21
a.append(b)就行,不用再赋值给a。
f1帮助文档:只是在末尾增加一个元素,并不会返回一个新的list。
list ...
这样啊,谢谢大佬!
页:
[1]