我知道在R中,你只需鍵入?「function_name」。你如何在Python中做到這一點?具體而言,我試圖在pyplot
庫中找到有關set_position
的信息。如何在python中查找有關函數的信息?
5
A
回答
8
help(function)
應該這樣做。
演示:
def func():
"""
I am a function who doesn't do anything,
I just sit in your namespace and crowd it up.
If you call me expecting anything
I'll just return to you the singleton None
"""
pass
help(func)
2
在ipython
其supereasy - 只是追加?
(或??
用於與源代碼的擴展信息)到所討論的功能。
我matplotlib
交互工作時,總是使用它:
In [2]: from matplotlib.axes import Axes
In [3]: Axes.set_position??
Type: instancemethod
String Form:<unbound method Axes.set_position>
File: /home/tzelleke/.local/modules/active_python_2.7/lib/python2.7/site-packages/matplotlib/axes.py
Definition: Axes.set_position(self, pos, which='both')
Source:
def set_position(self, pos, which='both'):
"""
Set the axes position with::
pos = [left, bottom, width, height]
in relative 0,1 coords, or *pos* can be a
:class:`~matplotlib.transforms.Bbox`
There are two position variables: one which is ultimately
used, but which may be modified by :meth:`apply_aspect`, and a
second which is the starting point for :meth:`apply_aspect`.
Optional keyword arguments:
*which*
========== ====================
value description
========== ====================
'active' to change the first
'original' to change the second
'both' to change both
========== ====================
"""
if not isinstance(pos, mtransforms.BboxBase):
pos = mtransforms.Bbox.from_bounds(*pos)
if which in ('both', 'active'):
self._position.set(pos)
if which in ('both', 'original'):
self._originalPosition.set(pos)
In [4]:
3
嘗試在ipython
運行,在這種情況下,你可以輸入:
In [1]: from matplotlib import pyplot as pl
In [2]: pl.set_position?
Object `pl.set_position` not found.
在這裏,你必須使用google找出set_position
是Axes
類的一種方法:
In [3]: pl.Axes.set_position?
Type: instancemethod
String Form:<unbound method Axes.set_position>
File: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes.py
Definition: pl.Axes.set_position(self, pos, which='both')
Docstring:
Set the axes position with::
pos = [left, bottom, width, height]
in relative 0,1 coords, or *pos* can be a
:class:`~matplotlib.transforms.Bbox`
There are two position variables: one which is ultimately
used, but which may be modified by :meth:`apply_aspect`, and a
second which is the starting point for :meth:`apply_aspect`.
Optional keyword arguments:
*which*
========== ====================
value description
========== ====================
'active' to change the first
'original' to change the second
'both' to change both
========== ====================
相關問題
- 1. 如何在分佈式環境中有效查找有關UUID的信息?
- 2. 如何在snmp信息中找到有關eth0設備的信息?
- 3. 如何查找有關Fortran命令的各種信息?
- 4. 有關函數RegQueryInfoKey的詳細信息?
- 5. 如何獲取有關C函數的調用者的信息?
- 6. 查找有關Drupal視圖中的字段的信息
- 7. AngularJs - 在兩個數組中查找關係信息
- 8. 如何在C++中使用sysconf()函數來查找以下信息?
- 9. 查找更多有關數據庫信息
- 10. 查找具有特定關鍵字的所有輸入信息
- 11. 如何讓PostgresSQL在PL函數中使用查詢信息?
- 12. apropos /查找上下文相關信息
- 13. 使用Python在{{}}中查找由JavaScript填充的信息
- 14. 在Python中查找並只提取所需的信息
- 15. help()在Python中找到信息?
- 16. 如何在Python中查找leastsq函數的初始猜測?
- 17. python函數打破n行的信息
- 18. 如何從C中查找Python函數的參數數量?
- 19. 查找有關計算視圖的信息?
- 20. Javascript若要查找有關訪客的信息
- 21. Discord.py - 查找有關發件人的信息
- 22. 如何從AMI id找出有關EC2實例的信息?
- 23. 查詢有關文件的信息android
- 24. 有關SPARQL查詢的信息
- 25. 如何查找有關安裝odp.net使用註冊表的詳細信息?
- 26. 如何從jpcap查找信息字段
- 27. 如何在調試時在Visual Studio中查看有關HWND的信息?
- 28. 有關`({});`在C中的更多信息?
- 29. 在Python 2.5中打印有關異常的信息?
- 30. 有關計算機在Python中的信息
所以我輸入pyplot作爲plt。我想調整我的情節的位置。當我輸入help(pl.set_position)或help(set_position)時,我收到一條錯誤消息。 – lord12 2013-02-22 17:08:57
@ lord12 - 這是因爲'plt.set_position'不存在...您首先需要知道哪裏可以找到您的功能。 – mgilson 2013-02-22 17:10:59
接受提案以更好地編寫文檔串的最後一行--- http://www.youtube.com/watch?v=XaWU1CmrJNc – mgilson 2013-02-22 17:12:02