当我在IPython控制台中键入斜杠时,它返回一个空元组:
In[1]: /
Out[1]: ()
这是为什么?我在Mac上。我正在使用Jupyter QtConsole和Python 3.5.2。
答案 0 :(得分:3)
从输入?
并在IPython中读取它:
您可以使用'/'作为第一个字符来强制使用自动括号 一条线。例如::
In [1]: /globals # becomes 'globals()'
请注意,'/'必须是该行的第一个字符!这个 不会起作用::
In [2]: print /globals # syntax error
所以/
本身只是在它之后的单词中加上括号。如果没有单词,您只需获得()
。
答案 1 :(得分:1)
You can force automatic parentheses by using ‘/’ as the first character of a line.
使用正斜杠添加括号:
/print 1 2 3
相当于:
print(1, 2, 3)