use*_*465 0 python parentheses
d=dict(a=1)
Run Code Online (Sandbox Code Playgroud)
以下两者有什么区别?
d.clear
d.clear()
Run Code Online (Sandbox Code Playgroud)
为什么不能先清字典?
使用括号调用函数,而不使用它们会创建对该函数的引用。
见下文:
>>> def t():
... return "Hi"
...
>>> a = t
>>> a
<function t at 0x01BECA70>
>>> a = t()
>>> a
'Hi'
>>>
Run Code Online (Sandbox Code Playgroud)
这里有一个很好的链接可以进一步解释:http : //docs.python.org/2/tutorial/controlflow.html(向下滚动到“定义函数”部分)。