Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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,我正在学习python,遇到了一些问题 当我们导入整个模块(*)或一些需要的函数时,如何查看这些函数的用法 例: 我有很多来自数学模块的函数,但是如何使用它们,它们需要1 arg或更多,或者如何使用。 例:如何使用cos或如何使用floor等 我可以获得模块数学的用法,但需要模块用法中的函数 上述 import math dir(math) ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__',

我正在学习python,遇到了一些问题 当我们导入整个模块(*)或一些需要的函数时,如何查看这些函数的用法 例:

我有很多来自数学模块的函数,但是如何使用它们,它们需要1 arg或更多,或者如何使用。 例:如何使用
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']