【Python】【基础知识】【内置函数】【help的使用方法】

原英文帮助文档:

help([object])

Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

This function is added to the built-in namespace by the site module.

Changed in version 3.4: Changes to pydoc and inspect mean that the reported signatures for callables are now more comprehensive and consistent.

————————(我是分割线)————————

中文解释

调用内置的帮助系统。(这个函数用于交互模式使用)

如果未给出参数,则交互帮助系统将在解释器控制台上启动。

示例:

>>> help
Type help() for interactive help, or help(object) for help about object.
>>> help()

Welcome to Python 3.7‘s help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at https://docs.python.org/3.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> abs
Help on built-in function abs in module builtins:

abs(x, /)
    Return the absolute value of the argument.

help> input
Help on built-in function input in module builtins:

input(prompt=None, /)
    Read a string from standard input.  The trailing newline is stripped.

    The prompt string, if given, is printed to standard output without a
    trailing newline before reading input.

    If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
    On *nix systems, readline is used if available.

help> input()
No Python documentation found for ‘input()‘.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

help> quit

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help(‘string‘)"
has the same effect as typing a particular string at the help> prompt.
>>> 

---退出帮助模式使用quit

如果参数是字符串,则该字符串将作为模块、函数、类、方法、关键字或文档主题的名称查找,并在控制台上打印帮助页。

>>> help("time")
Help on built-in module time:

NAME
    time - This module provides various functions to manipulate time values.

DESCRIPTION
    There are two standard representations of time.  One is the number
    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer
    or a floating point number (to represent fractions of seconds).
    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.
    The actual value can be retrieved by calling gmtime(0).

    The other representation is a tuple of 9 integers giving local time.
    The tuple items are:
      year (including century, e.g. 1998)
      month (1-12)
      day (1-31)
      hours (0-23)
      minutes (0-59)
      seconds (0-59)
      weekday (0-6, Monday is 0)
      Julian day (day in the year, 1-366)
      DST (Daylight Savings Time) flag (-1, 0 or 1)
    If the DST flag is 0, the time is given in the regular time zone;
    if it is 1, the time is given in the DST time zone;
    if it is -1, mktime() should guess based on the date and time.

CLASSES
    builtins.tuple(builtins.object)
        struct_time

    class struct_time(builtins.tuple)
     |  struct_time(iterable=(), /)......

如果参数是任何其他类型的对象,则会生成该对象的帮助页。

>>> a = "test"
>>> help(a)
Help on package test:

NAME
    test - # Dummy file to make this directory a package.

PACKAGE CONTENTS
    __main__
    _test_multiprocessing
    ann_module
    ann_module2
    ann_module3
    audiotests
    autotest
    bad_coding
    bad_coding2
    bad_getattr
    bad_getattr2
    bad_getattr3
    badsyntax_3131
    badsyntax_future10
    badsyntax_future3
    badsyntax_future4
    badsyntax_future5
    badsyntax_future6
    badsyntax_future7
    badsyntax_future8
    badsyntax_future9
    badsyntax_pep3120
    bisect
    bytecode_helper......
>>> help("ls")
No Python documentation found for ‘ls‘.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

此函数由站点模块添加到内置命名空间中。

版本3.4中的更改:pydoc和inspect的更改意味着所报告的可调用签名现在更加全面和一致。

———————(我是分割线)————————

————————(我是分割线)————————

参考:

1. Python 3.7.2 documentation

2. RUNOOB.COM:https://www.runoob.com/python/python-func-help.html

备注:

初次编辑时间:2019年9月21日21:08:21

环境:Windows 7   / Python 3.7.2

原文地址:https://www.cnblogs.com/kaixin2018/p/11565120.html

时间: 2024-11-02 18:52:54

【Python】【基础知识】【内置函数】【help的使用方法】的相关文章

python基础知识内置函数(二)、装饰器

一.内置函数 1.chr()  ord() r= chr(65) #ASCII对应的字母 print (r) n= ord("a") #ASCII对应的数字 print(n) #以下为执行结果 A 97 可以利用此函数随机生成验证码: import random li=[] for i in range(6): r = random.randrange(0,5) if r ==2 or r==4: num = random.randrange(0,10) li.append(str(n

Python基础day-11[内置函数(未完),递归,匿名函数]

内置函数: abs() : 返回数字的绝对值.参数可以是整数或浮点数,如果参数是复数,则返回复数的模. print(abs(0.2)) print(abs(1)) print(abs(-4)) print(abs(-0.2)) print(abs(3+4j)) 执行结果: D:\Python\Python36-32\python.exe E:/Python/DAY-11/tmp.py 0.2 1 4 0.2 5.0 Process finished with exit code 0 all():

第六篇:python基础_6 内置函数与常用模块(一)

本篇内容 内置函数 匿名函数 re模块 time模块 random模块 os模块 sys模块 json与pickle模块 shelve模块 一. 内置函数 1.定义 内置函数又被称为工厂函数. 2.常用的内置函数 (1)abs() #!/usr/binl/env python #encoding: utf-8 #author: YangLei print(abs(-1)) (2)all() #!/usr/binl/env python #encoding: utf-8 #author: Yang

python 基础 学习 内置函数

内置函数       例:如果返回数字的绝对值 ,写函数是非常不方便的 [[email protected] tools]# python fa.py  10 [[email protected] tools]# cat fa.py  #!/usr/bin/python def a(x):     if x < 0 :         return -x      return x  n = a(-10) print n  #帮助查看# >>> help(len) 用法: help

Python 基础5:内置函数一

===========内置函数=========== 1.abs绝对值 #abs() i = abs(-123) print(i) #结果:123 2.all与any #all 循环参数,如果每个元素都为真,那么all的返回值为真 #any,只要有一个是真的,则为真 r = all([True,True,False]) print(r) #结果:False #元素为假的有:0,None,空的字符串.列表.元组.字典 3.ascii,对象的类中找__repr__,获取齐返回值 # class Fo

python基础学习-内置函数

#!/usr/bin/env python # -*- coding:utf-8 -*- 系统内置函数 n =abs(-1) #绝对值 print(n) #bytes()函数 s="离开" re= bytes(s,encoding="utf-8")  # bytes() 把字符串 转换成字节 print(re) res = str(re,encoding="utf-8") #转换回字符串 print(res) re= bytes(s,encodi

Python基础编程 内置函数

内置函数 内置函数(一定记住并且精通) print()屏幕输出 int():pass str():pass bool():pass set(): pass list() 将一个可迭代对象转换成列表 tuple() 将一个可迭代对象转换成元组 dict() 通过相应的方式创建字典. # 创建字典的几种方式 #直接创建 dic = {1: 2} #字典推导式 print({i: 1 for i in range(3)}) dict() #dict创建 dic = dict(one=1, two=2,

学习PYTHON之路, DAY 4 - PYTHON 基础 4 (内置函数)

注:查看详细请看https://docs.python.org/3/library/functions.html#next 一 all(), any() False: 0, Noe, '', [], {}, () all()  全部为真是, 才为真 any() 任何一个为真, 都为真 二 bin(), oct(),hex() bin(), 接收十进制转二进制 (0b) oct(), 接收十进制转八进制 (0o) hex(), 接收十进制转十六进制 (0x) 三 bytes() bytes(只要转

python基础:内置函数zip,map,filter

一.zip zip,就是把俩list,合并到一起,如果想同时循环2个list的时候,可以用zip,会帮你轮流循环两个list 比如: l1=[1,2,3,4,5] l2=['a','b','c','d','e'] for a,b in zip(l1,l2): print(a,b) #得到的结果就是1 a2 b3 c4 d5 e 如果两个list的长度不一致,则以长度小的为依据 比如: l1=[1,2,3,4] l2=['a','b','c','d','e'] for a,b in zip(l1,

python之路——内置函数与匿名函数

内置函数 python里的内置函数.截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是python提供给你直接可以拿来使用的所有函数.这些函数有些我们已经用过了,有些我们还没用到过,还有一些是被封印了,必须等我们学了新知识才能解开封印的.那今天我们就一起来认识一下python的内置函数.这么多函数,我们该从何学起呢? 上面就是内置函数的表,68个函数都在这儿了.这个表的顺序是按照首字母的排列顺序来的,你会发现都混乱的堆在一起.比如,oct和bin和hex都