Python 3.10.4下载及安装
Python官网: Welcome to Python.org
首页,Downloads菜单,
点击“Python 3.10.4”,开始下载安装包,下载完成后得到文件“python-3.10.4-amd64.exe”(我的笔记本电脑使用的是AMD的CPU,应该是Python官网服务器能根据浏览器的访问信息得到客户端计算机的相关信息):
双击该文件即开始安装,
点击“Customize installation”(定制安装)
指定安装位置“d:\Programs\Python\Python310”。点击“Install”
等待一段时间后,完成安装。
点击“Close”即可。
在Windows的开始菜单中,添加了几个新的菜单项:
安装目录信息截图如下:
在命令行使用help查看模块信息
在Windows中可以在开始菜单中点击“Python 3.10 Module Docs”,在窗口中查看。
但是在命令行中查看更方便些。
由于在安装时,将Python的安装目录加入到系统变量PATH中,所以可以在命令行直接进入。
在命令行依次键入命令python,进入Python。依次键入下列命令
help()
modules
即可显示Python的所有模块
显示的模块名整理到一个表中(大概是296个),如下表所示
__future__ | _thread | getopt | runpy |
_abc | _threading_local | getpass | sched |
_aix_support | _tkinter | gettext | secrets |
_ast | _tracemalloc | glob | select |
_asyncio | _uuid | graphlib | selectors |
_bisect | _warnings | gzip | setuptools |
_blake2 | _weakref | hashlib | shelve |
_bootsubprocess | _weakrefset | heapq | shlex |
_bz2 | _winapi | hmac | shutil |
_codecs | _xxsubinterpreters | html | signal |
_codecs_cn | _zoneinfo | http | site |
_codecs_hk | abc | idlelib | smtpd |
_codecs_iso2022 | aifc | imaplib | smtplib |
_codecs_jp | antigravity | imghdr | sndhdr |
_codecs_kr | argparse | imp | socket |
_codecs_tw | array | importlib | socketserver |
_collections | ast | inspect | sqlite3 |
_collections_abc | asynchat | io | sre_compile |
_compat_pickle | asyncio | ipaddress | sre_constants |
_compression | asyncore | itertools | sre_parse |
_contextvars | atexit | json | ssl |
_csv | audioop | keyword | stat |
_ctypes | base64 | lib2to3 | statistics |
_ctypes_test | bdb | linecache | string |
_datetime | binascii | locale | stringprep |
_decimal | binhex | logging | struct |
_distutils_hack | bisect | lzma | subprocess |
_elementtree | builtins | mailbox | sunau |
_functools | bz2 | mailcap | symtable |
_hashlib | cProfile | marshal | sys |
_heapq | calendar | math | sysconfig |
_imp | cgi | mimetypes | tabnanny |
_io | cgitb | mmap | tarfile |
_json | chunk | modulefinder | telnetlib |
_locale | cmath | msilib | tempfile |
_lsprof | cmd | msvcrt | test |
_lzma | code | multiprocessing | textwrap |
_markupbase | codecs | netrc | this |
_md5 | codeop | nntplib | threading |
_msi | collections | nt | time |
_multibytecodec | colorsys | ntpath | timeit |
_multiprocessing | compileall | nturl2path | tkinter |
_opcode | concurrent | numbers | token |
_operator | configparser | opcode | tokenize |
_osx_support | contextlib | operator | trace |
_overlapped | contextvars | optparse | traceback |
_pickle | copy | os | tracemalloc |
_py_abc | copyreg | pathlib | tty |
_pydecimal | crypt | pdb | turtle |
_pyio | csv | pickle | turtledemo |
_queue | ctypes | pickletools | types |
_random | curses | pip | typing |
_sha1 | dataclasses | pipes | unicodedata |
_sha256 | datetime | pkg_resources | unittest |
_sha3 | dbm | pkgutil | urllib |
_sha512 | decimal | platform | uu |
_signal | difflib | plistlib | uuid |
_sitebuiltins | dis | poplib | venv |
_socket | distutils | posixpath | warnings |
_sqlite3 | doctest | pprint | wave |
_sre | | profile | weakref |
_ssl | encodings | pstats | webbrowser |
_stat | ensurepip | pty | winreg |
_statistics | enum | py_compile | winsound |
_string | errno | pyclbr | wsgiref |
_strptime | faulthandler | pydoc | xdrlib |
_struct | filecmp | pydoc_data | xml |
_symtable | fileinput | pyexpat | xmlrpc |
_testbuffer | fnmatch | queue | xxsubtype |
_testcapi | fractions | quopri | zipapp |
_testconsole | ftplib | random | zipfile |
_testimportmultiple | functools | re | zipimport |
_testinternalcapi | gc | reprlib | zlib |
_testmultiphase | genericpath | rlcompleter | zoneinfo |
在命令行提示符为“help>”时,键入模块名,即可显示该模块的详细信息。比如键入pip,命令执行之后的效果如下图所示:
列出了NAME(模块名)、PACKAGE CONTENTS(包内容)、FUNCTIONS(函数)、DATA(数据)、VERSION(版本号)、FILE(文件,包含了目录)。
在命令行提示符为“help>”时,按下回车键,返回Python的命令行,提示符变为“>>>”。
可以使用import、dir、print、help命令显示包(模块)的一些信息,如下图所示:
其中键入的命令依次如下:
import pip
dir(pip)
help(pip.main)