0

这是我在将变量引用为元组时遇到的python中最有趣的事情。有人可以给我一个C语言的等价物吗???

h = 1,_,3,_

h
Out[2]: (1, '', 3, '')

 h = 1,'',3, ''

h
Out[5]: (1, '', 3, '')

这是怎么发生的?_ 和 '' 是否相等?有什么区别?

我想知道有多少这样的神奇引用是可能的?

4

1 回答 1

3

_IPython shell 中的默认值为''

monty@xonix:~/py$ ipython --classic
Python 2.7.4 (default, Apr 19 2013, 18:32:33) 
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
>>> _
''
>>> 2*2
4
>>> _  # Now _ returns the value of last expression
4
于 2013-06-12T08:37:59.297 回答