Python 我可以让空闲shell显示函数的描述吗?

Python 我可以让空闲shell显示函数的描述吗?,python,python-3.x,python-2.7,Python,Python 3.x,Python 2.7,所以我是Python新手,我使用IDLE。我使用什么命令,所以Python shell(按f5后)向我显示了描述(我在函数名后面的“”中编写的内容) 和/或显示其他功能的说明 如果在2.7和3.3中有所不同,如果您能提及,我将不胜感激。您使用: help(your_function_name) 就像我在这里做的那样: >>> def sayhello(): """This says hello to you""" print "Hello there!" &

所以我是Python新手,我使用IDLE。我使用什么命令,所以Python shell(按f5后)向我显示了描述(我在函数名后面的“”中编写的内容) 和/或显示其他功能的说明

如果在2.7和3.3中有所不同,如果您能提及,我将不胜感激。

您使用:

help(your_function_name)
就像我在这里做的那样:

>>> def sayhello():
    """This says hello to you"""
    print "Hello there!"

>>> help(sayhello)
Help on function sayhello in module __main__:

sayhello()
    This says hello to you
编辑: 您必须先导入自己的模块。

您使用:

help(your_function_name)
就像我在这里做的那样:

>>> def sayhello():
    """This says hello to you"""
    print "Hello there!"

>>> help(sayhello)
Help on function sayhello in module __main__:

sayhello()
    This says hello to you
编辑: 您必须先导入自己的模块。

调用“thing”,并且可以通过其dictionary属性轻松访问它

“thing”被调用,并且可以通过其dictionary属性轻松访问

在“”中写入的内容称为docstring

当您想要打印此文件时,可以使用类型的
\uuuu doc\uuu
属性。(类型表示类、方法或模块)

您可以使用内置函数检查可用属性,在“”中写入的内容称为docstring

当您想要打印此文件时,可以使用类型的
\uuuu doc\uuu
属性。(类型表示类、方法或模块)

您可以使用内置函数检查可用属性

use help()函数

例如:

帮助(打印) 关于内置函数打印模块内置内容的帮助:

打印(…) 打印(值,…,sep='',end='\n',file=sys.stdout,flush=False)

使用help()函数

例如:

帮助(打印) 关于内置函数打印模块内置内容的帮助:

打印(…) 打印(值,…,sep='',end='\n',file=sys.stdout,flush=False)


如果他需要一个字符串,这将不起作用,因为它会打印到std.out,需要使用pydoc module@Samuele中的render_doc方法:我知道,但他问他应该使用什么命令来向他显示描述。我知道:)我只是为了向他澄清而添加:)没问题:)。新手们必须知道他们到底能做多少。如果他需要一个字符串,这是行不通的,因为它会打印到std.out,需要使用pydoc module@Samuele中的render_doc方法:我知道,但他问他应该使用什么命令来显示描述。我知道:)我只是想向他澄清一下:)没问题:)。新来的人必须知道他们到底能做到多少。