为什么/返回IPython cons中的空元组

2024-04-26 23:04:19 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在IPython控制台中键入斜杠时,它返回一个空元组:

In[1]: /
Out[1]: ()

为什么会这样?我在mac电脑上。我将Jupyter QtConsole与python3.5.2结合使用。你知道吗


Tags: in键入macipythonjupyterout元组电脑
2条回答

通过键入?并在IPython中读取它:

You can force auto-parentheses by using '/' as the first character of a line. For example::

In [1]: /globals             # becomes 'globals()'

Note that the '/' MUST be the first character on the line! This won't work::

In [2]: print /globals    # syntax error

所以/本身只是在单词后面加上括号。如果没有消息,你只会得到()。你知道吗

You can force automatic parentheses by using ‘/’ as the first character of a line.

使用正斜杠添加括号:

/print 1 2 3

相当于:

print(1, 2, 3)

相关问题 更多 >