IPython正斜杠文档 [英] IPython forward slash documentation
本文介绍了IPython正斜杠文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不小心在IPython中发现了此功能:
I accidentally discovered this feature in IPython:
In [126]: def blah(): return 5
In [127]: /blah
Out[127]: 5
In [128]: /range 5 2 4
Out[128]: range(5, 2, 4)
In [133]: /int '100' base=16
Out[133]: 256
以正斜杠开头的行将带有逗号和自动插入函数调用括号.
A line starting with a forward slash will have commas and function call parens automatically inserted.
我在哪里可以找到更多?我似乎找不到它的文档.
Where do I find out more? I can't seem to find the docs for it.
推荐答案
如果在ipython中键入?
,您将获得内置文档:
If you type ?
in ipython you will get the builtin documentation:
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
In most cases the automatic algorithm should work, so you should
rarely need to explicitly invoke /. One notable exception is if you
are trying to call a function with a list of tuples as arguments (the
parenthesis will confuse IPython)::
In [1]: zip (1,2,3),(4,5,6) # won't work
but this will work::
In [2]: /zip (1,2,3),(4,5,6)
------> zip ((1,2,3),(4,5,6))
Out[2]= [(1, 4), (2, 5), (3, 6)]
IPython tells you that it has altered your command line by
displaying the new command line preceded by -->. e.g.::
In [18]: callable list
-------> callable (list)
相关的文档页面,其中包含其他功能.
The relevant docs page which includes other features.
从此处最基本的功能:
这篇关于IPython正斜杠文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文