Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问python中模块的所有内置函数的列表_Python - Fatal编程技术网

如何访问python中模块的所有内置函数的列表

如何访问python中模块的所有内置函数的列表,python,Python,如果我有一个名为“math”的模块,可以称为import“math”,那么我如何获得与“math”相关联的所有内置函数的列表呢?有一个函数,它列出了对象的所有(很好,基本上)属性。但只过滤函数不是问题: >>>import math >>>dir(math) ['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh',

如果我有一个名为“math”的模块,可以称为import“math”,那么我如何获得与“math”相关联的所有内置函数的列表呢?

有一个函数,它列出了对象的所有(很好,基本上)属性。但只过滤函数不是问题:

 >>>import math
 >>>dir(math)
 ['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
 >>>
 >>>[f for f in dir(math) if hasattr(getattr(math, f), '__call__')] # filter on functions
 ['acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
您可能会发现这是一个有用的资源,以及以下问题:。

这就是
help()
方便使用的地方(如果您喜欢人类可读的格式):

导入数学 >>>帮助(数学) 关于内置模块数学的帮助: 名称 数学 功能 acos(…) 助理文书主任(x) 返回x的弧余弦(以弧度为单位)。 acosh(…) acosh(x) 返回x的双曲弧余弦(以弧度为单位)。 asin(…)
仅适用于内置功能:

from inspect import getmembers, isfunction

functions_list = [o for o in getmembers(my_module, isfunction)]
from inspect import getmembers, isfunction

functions_list = [o for o in getmembers(my_module, isfunction)]