python自带help功能怎么使用

其他教程   发布日期:2023年11月13日   浏览次数:616

这篇“python自带help功能怎么使用”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“python自带help功能怎么使用”文章吧。

python help使用

  1. C:Userswusong>python
  2. Python 3.8.2rc1 (tags/v3.8.2rc1:8623e68, Feb 11 2020, 10:46:21) [MSC v.1916 64 bit (AMD64)] on win32
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>>

输入

  1. help()
  1. >>> help
  2. Type help() for interactive help, or help(object) for help about object.
  3. >>> help()
  4. Welcome to Python 3.8's help utility!
  5. If this is your first time using Python, you should definitely check out
  6. the tutorial on the Internet at https://docs.python.org/3.8/tutorial/.
  7. Enter the name of any module, keyword, or topic to get help on writing
  8. Python programs and using Python modules. To quit this help utility and
  9. return to the interpreter, just type "quit".
  10. To get a list of available modules, keywords, symbols, or topics, type
  11. "modules", "keywords", "symbols", or "topics". Each module also comes
  12. with a one-line summary of what it does; to list the modules whose name
  13. or summary contain a given string such as "spam", type "modules spam".
  14. help>

这句话:To get a list of available modules, keywords, symbols, or topics, type "modules", "keywords", "symbols", or "topics".

意思就是:

要获取可用模块、关键字、符号或主题的列表,请键入 “模块”、“关键字”、“符号”或“主题”。

modules

我们先看下modules

在help模式下输入:modules

  1. help> modules
  2. Please wait a moment while I gather a list of all available modules...
  3. D:software_installpythonlibpkgutil.py:92: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.
  4. __import__(info.name)
  5. PIL asyncpg idna selenium
  6. PyInstaller atexit imaplib serial
  7. PyQt5 atlastk imghdr setuptools
  8. __future__ attr imp shelve
  9. _abc attrs importlib shlex
  10. _ast audioop inspect shutil
  11. _asyncio backports io signal
  12. _bisect base64 ipaddress simplejson
  13. _blake2 bcrypt itertools site
  14. _bootlocale bdb jinja2 six
  15. _bz2 billiard json smtpd
  16. _cffi_backend binascii keyword smtplib
  17. _codecs binhex kiwisolver sndhdr
  18. _codecs_cn bisect kombu sniffio
  19. _codecs_hk broadcaster lib2to3 socket
  20. _codecs_iso2022 builtins libfuturize socketserver
  21. _codecs_jp bz2 libpasteurize socks
  22. _codecs_kr cProfile linecache sockshandler
  23. _codecs_tw calendar locale sortedcontainers
  24. _collections celery logging sqlalchemy
  25. _collections_abc certifi loguru sqlite3
  26. _compat_pickle cffi lzma sqlparse
  27. _compression cgi mailbox sre_compile
  28. _contextvars cgitb mailcap sre_constants
  29. _csv charset_normalizer markupsafe sre_parse
  30. _ctypes chunk marshal ssl
  31. _ctypes_test click math starlette
  32. _datetime click_didyoumean matplotlib stat
  33. _decimal click_plugins mimetypes statistics
  34. _dummy_thread click_repl mmap string
  35. _elementtree cmath modulefinder stringprep
  36. _functools cmd msilib struct
  37. _hashlib code msvcrt subprocess
  38. _heapq codecs multiprocessing sunau
  39. _imp codeop nacl symbol
  40. _io collections netrc symtable
  41. _json colorama nntplib sys
  42. _locale colorsys nt sysconfig
  43. _lsprof compileall ntpath tabnanny
  44. _lzma concurrent nturl2path tarfile
  45. _markupbase configparser numbers telnetlib
  46. _md5 contextlib numpy tempfile
  47. _msi contextvars opcode test
  48. _multibytecodec contourpy operator textwrap
  49. _multiprocessing copy optparse tftpy
  50. _opcode copyreg ordered_set this
  51. _operator crypt ordlookup threading
  52. _osx_support cryptography os time
  53. _overlapped csv outcome timeit
  54. _pickle ctypes packaging tkinter
  55. _py_abc curses paramiko token
  56. _pydecimal cv2 parser tokenize
  57. _pyinstaller_hooks_contrib cycler past tortoise
  58. _pyio databases pathlib trace
  59. _queue dataclasses pdb traceback
  60. _random datetime pefile tracemalloc
  61. _ruamel_yaml dateutil peutils trio
  62. _sha1 dbm pickle trio_websocket
  63. _sha256 decimal pickletools tty
  64. _sha3 deepdiff pip turtle
  65. _sha512 difflib pipes turtledemo
  66. _signal dis pkg_resources types
  67. _sitebuiltins distlib pkgutil typing
  68. _socket distutils platform typing_extensions
  69. _sqlite3 django platformdirs tzdata
  70. _sre doctest plistlib unicodedata
  71. _ssl dotenv poplib unittest
  72. _stat dummy_threading posixpath urllib
  73. _statistics easy_install pprint urllib3
  74. _string email prettytable uu
  75. _strptime encodings profile uuid
  76. _struct ensurepip prompt_toolkit uvicorn
  77. _symtable enum pstats venv
  78. _testbuffer errno psutil vine
  79. _testcapi fastapi pty virtualenv
  80. _testconsole faulthandler py_compile warnings
  81. _testimportmultiple filecmp pyclbr watchfiles
  82. _testmultiphase fileinput pycparser wave
  83. _thread filelock pydantic wcwidth
  84. _threading_local fnmatch pydoc weakref
  85. _tkinter fontTools pydoc_data webbrowser
  86. _tracemalloc formatter pyecharts websockets
  87. _warnings fractions pyexpat win32_setctime
  88. _weakref ftplib pylab win32ctypes
  89. _weakrefset functools pyparsing winreg
  90. _winapi future pyqt5_plugins winsound
  91. _xxsubinterpreters gc pyqt5_tools wsgiref
  92. _yaml genericpath pytz wsproto
  93. abc getopt qt5_applications xdrlib
  94. aifc getpass qt5_tools xlrd
  95. altgraph gettext queue xlwt
  96. amqp glob quopri xml
  97. antigravity greenlet random xmlrpc
  98. anyio gzip re xxsubtype
  99. argparse h21 reprlib yaml
  100. array hashlib requests zipapp
  101. asgiref heapq rlcompleter zipfile
  102. ast hmac runpy zipimport
  103. async_generator html sched zlib
  104. asynchat http secrets
  105. asyncio httptools select
  106. asyncore idlelib selectors
  107. Enter any module name to get more help. Or, type "modules spam" to search
  108. for modules whose name or summary contain the string "spam".
  109. help>

从这里可以看出还是有相当多的模块,比如我们常用的

  1. re
,
  1. xlrd
当然也有我们后期安装的;挑一个进去看看,有啥风景,就挑
  1. xlrd
  1. help> xlrd
  2. Help on package xlrd:
  3. NAME
  4. xlrd
  5. DESCRIPTION
  6. # Copyright (c) 2005-2012 Stephen John Machin, Lingfo Pty Ltd
  7. # This module is part of the xlrd package, which is released under a
  8. # BSD-style licence.
  9. PACKAGE CONTENTS
  10. biffh
  11. book
  12. compdoc
  13. formatting
  14. formula
  15. info
  16. sheet
  17. timemachine
  18. xldate
  19. FUNCTIONS
  20. count_records(filename, outfile=<colorama.ansitowin32.StreamWrapper object at 0x000001D26AC13D00>)
  21. For debugging and analysis: summarise the file's BIFF records.
  22. ie: produce a sorted file of ``(record_name, count)``.
  23. :param filename: The path to the file to be summarised.
  24. :param outfile: An open file, to which the summary is written.
  25. -- More -- 行数:

这里面会详细介绍

  1. xlrd
模块的名字,描述,模块目录、功能、版本、文件位置等信息,在最后一行看到
  1. -- More --
,这是一个分页符,表示当前页面不能全部显示所有信息,需要部分分页操作,可以使用空格键切换下一页,也可以使用回车键看下一行,看你自己的需求进行操作,如果不想看了可输入
  1. q
退出阅读模式,进入help模式,再输入
  1. q
则可以继续退出help模式;
  1. help> q
  2. You are now leaving help and returning to the Python interpreter.
  3. If you want to ask for help on a particular object directly from the
  4. interpreter, you can type "help(object)". Executing "help('string')"
  5. has the same effect as typing a particular string at the help> prompt.
  6. >>>

keywords

再看下我们后面会常说的关键字

  1. help> keywords
  2. Here is a list of the Python keywords. Enter any keyword to get more help.
  3. False class from or
  4. None continue global pass
  5. True def if raise
  6. and del import return
  7. as elif in try
  8. assert else is while
  9. async except lambda with
  10. await finally nonlocal yield
  11. break for not

symbols

这个是罗列了我们在python语言中涉及的运算符

  1. help> symbols
  2. Here is a list of the punctuation symbols which Python assigns special meaning
  3. to. Enter any symbol to get more help.
  4. != + <= __
  5. " += <> `
  6. """ , == b"
  7. % - > b'
  8. %= -= >= f"
  9. & . >> f'
  10. &= ... >>= j
  11. ' / @ r"
  12. ''' // J r'
  13. ( //= [ u"
  14. ) /= u'
  15. * : ] |
  16. ** < ^ |=
  17. **= << ^= ~
  18. *= <<= _

以上就是python自带help功能怎么使用的详细内容,更多关于python自带help功能怎么使用的资料请关注九品源码其它相关文章!