在哪里找python的答案_help()在哪里找到Python中的信息?

我最近发现了内置的help(),它为模块,函数,方法,类等打印了一些信息.但它究竟在哪里找到它显示的信息?

Python docs没有给出一个关于此的提示.

>>> import base64

>>> help(base64)

Help on module base64:

NAME

base64 - RFC 3548: Base16, Base32, Base64 Data Encodings

FILE

/usr/lib/python2.7/base64.py

..

最佳答案 如果你只是做,帮助(帮助),你会得到

Help on _Helper in module site object:

class _Helper(__builtin__.object)

| Define the builtin 'help'.

| This is a wrapper around pydoc.help (with a twist).

|

| Methods defined here:

|

| __call__(self, *args, **kwds)

|

| __repr__(self)

|

| ----------------------------------------------------------------------

| Data descriptors defined here:

|

| __dict__

| dictionary for instance variables (if defined)

|

| __weakref__

| list of weak references to the object (if defined)

基本上,帮助从pydoc.help获取输入.引用,pydoc documentation,

For modules, classes, functions and methods, the displayed documentation is derived from the docstring (i.e. the __doc__ attribute) of the object, and recursively of its documentable members. If there is no docstring, pydoc tries to obtain a description from the block of comment lines just above the definition of the class, function or method in the source file, or at the top of the module (see inspect.getcomments()).

The built-in function help() invokes the online help system in the interactive interpreter, which uses pydoc to generate its documentation as text on the console.

But where exactly does it find the information it shows?

上面引用的粗体文字回答了这个问题.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值