为什么变量不能设置为等于Python中的函数调用?

use*_*711 -1 python list python-3.x

c = None在Python命令行中解释为什么在以下Python 3示例中.

>>> a = [1,2]
>>> b = a
>>> c = b.append(3)
>>> print(a,b,c)
[1, 2, 3] [1, 2, 3] None
Run Code Online (Sandbox Code Playgroud)

Moi*_*dri 5

list.append()将该条目附加到位并返回Python所采用的任何内容(Python的None默认行为).例如:

>>> def foo():
...     print "I am in Foo()"
...     # returns nothing
...
>>> c = foo()   # function call
I am in Foo()
>>> c == None
True   # treated as true
Run Code Online (Sandbox Code Playgroud)