Python day01
第一天简单介绍了Python,配置环境变量的方法,一些简单的CMD命令行。
第一节(简单介绍)
Python:蟒蛇 Life is short,you need Python //人生苦短,我学Python。
Python是一种解释性的,面向对象,高级程序语言。
解释性:xxx.py–>编译并执行—>结果
Java 编译型:xxx.java—>编译:xxx.class---->执行class文件---->结果.
Python创建初心:
1.简单直观
2.开源
3.容易理解
4.短期开发
Python方向(举例):
Linux +web(网站): 运维
Web(网站):网站开发(爬虫)
数据分析+爬虫:
Python特点:
1.Python是完全面向对象的语言:函数,模块,字符串,数字都是对象,在Python中一切皆是对象。
2.Python拥有强大的标准库:比如:time,datetime,random,hashlib,re,…
3. Python 社区提供了大量的第三方模块,使用方式与标准库类似。它们的功能覆盖 科学计算、人工智能、机器学习、Web 开发、数据库接口、图形系统 多个领域
4. 简单易懂,代码简洁
5. 跨平台
6. 免费、开源
第二节(配置环境变量)
1.可以进入Python官网(后缀为org),下载Python版本如3.7.0 (zip为压缩文件,exe为可执行文件),在安装:要注意勾选: add to path 目的: 使用python和pip命令
2.右击我的电脑,点击属性,点击左侧高级系统设置打开环境变量进行配置
用户变量中path路径为C盘目录下用户隐藏的AppData文件中(可于查看中显示)
系统变量优先,若有两个版本,例如3.6.5和3.7.0版本,想优先使用3.6.5版本就把3.6.5移入第一行。
C:\Users\running\AppData\Local\Programs\Python\Python36 ----》 python的安装路径
可以使用: Python.exe
C:\Users\running\AppData\Local\Programs\Python\Python36\Scripts —》
可以使用: pip.exe
用户PATH:
PATH:
C:\Users\running\AppData\Local\Programs\Python\Python37\Scripts;
C:\Users\running\AppData\Local\Programs\Python\Python37;
C:\Users\running\AppData\Local\Programs\Python\Python36\Scripts;
C:\Users\running\AppData\Local\Programs\Python\Python36;
C:\Users\running\AppData\Roaming\npm;
%WebStorm%;
%PyCharm Community Edition%
系统PATH:
%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;
C:\software\mysql-8.0.15-winx64\bin;
C:\Program Files\nodejs;
C:\Program Files\PuTTY;
C:\Users\running\AppData\Local\Programs\Python\Python36;
C:\Users\running\AppData\Local\Programs\Python\Python36\Scripts
第三节(简单的CMD命令及pip安装)
命令行:cmd
Cd 要切换的目录
Dir 浏览文件夹
Ping 传给另一台主机一个数据包等待回应,看是否连通
Ipconfig 查看本机IP地址
Mkdir 创建文件夹
…
Python:
通过python命令
- 进入交互式环境>>> print(‘hello world’)
特点: 一句一执行 - Python 源代码 编译执行
Python hello.py
将hello.py加载到解释器(动态加载一些库builtins.py),自上而下执行代码
Pip:
…/Scripts/pip.exe(位于)
是Python 包管理器
管理的是python第三方包下载
Python 的库:
- 标准库:
- 第三方库:
Pip管理包:
- pip install 包名字 : pip install requests,pip install pillow,pip install flask
Pip install django==版本号 - Pip uninstall 包名字
- Pip list 查看安装的第三方包
- Pip freeze > requirements.txt 将第三方的包输出到一个文件中,文件名:requirements.txt
Pip install -r requirements.txt 将 requirements.txt文件中的所有的第三方包一次性安装
(certifi=2019.6.16
chardet=3.0.4
Django=2.0
idna=2.8
Pillow=6.1.0
pytz=2019.1
sqlparse=0.3.0
urllib3=1.25.3)
写一段简单的小代码`.
//
#hello.py
print('hello world!')
print('hello world!')
print('hello world!')
print(max(1,3,6,7,9))
代码/hello.py //执行
hello world!
hello world!
hello world!
9 //输出结果
# test.py
# requests 浏览器
import requests
response = requests.get('https://www.baidu.com/')
print(response.text)
/test.py //执行
<!DOCTYPE html>.................//输出结果 已省略
2019/7/22/21:51