python dir方法_Python dir命令来确定方法

尽管GP89似乎已经回答了这个问题,但我想我还是要多说一些细节。在

首先,GP89的建议是使用Python内置的^{} method。这是一种可以在交互式控制台中使用的方法。对于方法,它将打印方法的声明行以及类“docstring”(如果已定义)。您也可以使用.__doc__来访问它,例如:>>> def testHelp(arg1, arg2=0):

... """This is the docstring that will print when you

... call help(testHelp). testHelp.__doc__ will also

... return this string. Here is where you should

... describe your method and all its arguments."""

...

>>> help(testHelp)

Help on function testHelp in module __main__:

testHelp(arg1, arg2=0)

This is the docstring that will print when you

call help(testHelp). testHelp.__doc__ will also

return this string. Here is where you should

describe your method and all its arguments.

>>>

然而,对于理解方法、类和函数,另一个极其重要的工具是工具箱的API。对于内置的Python函数,应该检查Python Doc Library。我在那里找到了help()函数的文档。您使用的是wxPython,其API可以在here找到,因此可以快速搜索“wx.框架api“并且您可以发现this page describing all of ^{}'s methods and variables.不幸的是,CreatteToolBar()并不是特别好的文档,但是您仍然可以看到它的参数:CreateToolBar(self, style, winid, name)

编码快乐!在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值