_在python中返回最后一个函数结果

时间:2014-07-12 19:06:40

标签: python

好的,我有一些适合你的人,我在新的新python终端中输入这段代码:

>>> print _
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> 'magic'[::2]
'mgc'
>>> print _
mgc
>>> 'magic'[::-1]
'cigam'
>>> print _
cigam

或:

>>> def foo(x):
...     return x * x
... 
>>> print _
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> foo(3)
9
>>> print _
9

这是正常的python行为吗?

0 个答案:

没有答案