Get help of python and python package function/获取python及python包函数的帮助文档

摘要:快速获取函数的帮助文档是阅读陌生程序的需求,也是学习编程语言的有效方法。对于python和python包,均有这样的支持。这里以numpy为例,说明其获取帮助的方法,其一使用包提供的帮助函数,其二查找帮助文档,当然还有其三万能的google。

Method 1: using help function or method

For general python function, help() function return the help of general python functions.

e.g.

help(max)

For numpy methods (functions), np.info() method return the help of numpy methods (functions).

e.g.

import numpy as np

np.info(np.maximum)

 

Method 2:using reference doc

search in ‘Index’ of reference doc

https://docs.scipy.org/doc/numpy/numpy-ref-1.14.5.pdf

e.g. maximum in page 826 of reference book

Function:

numpy.maximum(x1, x2, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj]) = <ufunc ‘maximum’>

Description:

Element-wise maximum of array elements.

Compare two arrays and returns a new array containing the element-wise maxima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.

Example:

data = numpy.random.randn(10,20)

data_relu = numpy.maximum(data, 0)

# get max of data and 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值