Python中模块的函数用法
我正在学习python,遇到了一些问题 当我们导入整个模块(*)或一些需要的函数时,如何查看这些函数的用法 例: 我有很多来自数学模块的函数,但是如何使用它们,它们需要1 arg或更多,或者如何使用。 例:如何使用Python中模块的函数用法,python,Python,我正在学习python,遇到了一些问题 当我们导入整个模块(*)或一些需要的函数时,如何查看这些函数的用法 例: 我有很多来自数学模块的函数,但是如何使用它们,它们需要1 arg或更多,或者如何使用。 例:如何使用cos或如何使用floor等 我可以获得模块数学的用法,但需要模块用法中的函数 上述 import math dir(math) ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__',
cos
或如何使用floor
等
我可以获得模块数学的用法,但需要模块用法中的函数
上述
import math
dir(math)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc']
就像dir()一样,寻找一些东西来了解如何使用模块内的每个函数
目前我在MAC上使用Python2.6和Python3.5您只需使用RTFM。。。这是最好的方法试试ipython,键入func?或者func???您是否尝试过
帮助
?比如help(math.cos)
import math
dir(math)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc']