查看 Python 版本,并编写第一个程序
C:\Users\dell\learn_python3_spider>python -V
Python 3.9.1
C:\Users\dell\learn_python3_spider>python
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, World!")
Hello, World!
>>> exit()
C:\Users\dell\learn_python3_spider>
使用脚本运行程序
C:\Users\dell>mkdir code
C:\Users\dell>cd code
C:\Users\dell\code>start .
C:\Users\dell\code>type helloworld.py
#!/usr/bin/python3
print("Hello, World!")
C:\Users\dell\code>python helloworld.py
Hello, World!
python保留字
C:\Users\dell\code>python
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
>>>
Python3 简介
解释型语言
交互式语言
面向对象语言
查看环境变量
C:\Users\dell>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\dell\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-0OKQ3CE
ComSpec=C:\Windows\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
GOPATH=C:\Users\dell\go
HOMEDRIVE=C:
HOMEPATH=\Users\dell
LOCALAPPDATA=C:\Users\dell\AppData\Local
LOGONSERVER=\\DESKTOP-0OKQ3CE
NUMBER_OF_PROCESSORS=8
OneDrive=C:\Users\dell\OneDrive
OS=Windows_NT
Path=D:\Program Files\Xshell 6\;D:\Program Files\VMware\VMware Workstation\bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Program Files\Git\Git\cmd;D:\Program Files\go\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\dell\AppData\Local\Microsoft\WindowsApps;C:\Users\dell\go\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=9e0d
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\dell\AppData\Local\Temp
TMP=C:\Users\dell\AppData\Local\Temp
USERDOMAIN=DESKTOP-0OKQ3CE
USERDOMAIN_ROAMINGPROFILE=DESKTOP-0OKQ3CE
USERNAME=ZhouLiang
USERPROFILE=C:\Users\dell
windir=C:\Window
C:\Users\dell>where python
C:\Users\dell\AppData\Local\Microsoft\WindowsApps\python.exe
查看安装的库
C:\Users\dell\HelloWorld\app01>pip list Package Version
asgiref 3.3.1 certifi 2020.12.5 chardet 4.0.0 Django 3.1.7 idna 2.10 Markdown 3.3.4 numpy 1.20.1 pandas 1.2.3 pip 21.0.1 PyMySQL 1.0.2 python-dateutil 2.8.1 pytz 2021.1 requests 2.25.1 setuptools 49.2.1 six 1.15.0 sqlparse 0.4.1 urllib3 1.26.3 xlwt 1.3.0
pip包管理器
pip 最常用的命令有以下几个:
查看版本:pip --version
安装:pip install 包名
升级:pip install -U 包名
卸载:pip uninstall 包名
列出已经安装的包:pip list