python 学习----使用帮助文档

   作为一个一直使用c作为开发语言的开发者,最近尝试学习一下python语言(不要问为什么选择python,我也不知道),那么提起来学习,怎么能想我写c语言一样,通过   man page 一样查看函数说明,相信python也同样也有这样功能。
 
  python 就提供了两个函数,dir() ,help()

 

1、dir    用来查询一个类或者对象所有属性

  dir()提供一个模块名字时,它返回在那个模块中定义的名字的列表。当没有为其提供参数时, 它返回当前模块中定义的名字的列表。

  >>> import math

>>> dir(math) # 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']>>>


2、help  查看函数帮助实例

>>> help(abs) # 查看abs函数

Help on built-in function abs in module __builtin__:

abs(...)

abs(number) -> number

Return the absolute value of the argument.

>>> help(math) # 查看math模块,此处只显示部分内容

Help on built-in module math:

NAME

math

FILE

(built-in)

DESCRIPTION

This module is always available. It provides access to the

mathematical functions defined by the C standard.

FUNCTIONS

acos(...)

acos(x)

Return the arc cosine (measured in radians) of x.

.....



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值