python: how to get information about a function?

后端 未结 4 1712
北荒
北荒 2020-11-29 03:50

When information about a type is needed you can use:

my_list = []
dir(my_list)

gets:

[\'__add__\', \'__class__\', \'__conta         


        
4条回答
  •  时光说笑
    2020-11-29 04:29

    In python: help(my_list.append) for example, will give you the docstring of the function.

    >>> my_list = []
    >>> help(my_list.append)
    
        Help on built-in function append:
    
        append(...)
            L.append(object) -- append object to end
    

提交回复
热议问题