编辑本文
目录
(一)python 环境准备
1,python 安装
2, 虚拟环境安装
3, 修改 pip 镜像源
4, 运行 python 程序
(二)python 语法
1, 数据类型
2, 数据操作(方法)
3,python 理论特点
4, 函数
5, 类
6, 框架, 系统
7, 多任务
8, 装饰器
9, 迭代器, 生成器
正文
(一)python 环境准备
1,python 安装
python3 安装在 Linux 上: https://www.cnblogs.com/andy9468/p/10437344.html
2, 虚拟环境安装
安装虚拟环境: https://www.cnblogs.com/andy9468/p/10437344.html
Windows 上安装 python 虚拟环境 https://www.cnblogs.com/andy9468/p/11006950.html
3, 修改 pip 镜像源
pip 升级
python 修改镜像源 https://www.cnblogs.com/andy9468/p/9982154.html
4, 运行 python 程序
Linux: 解决 nohup 中不写入日志的问题 https://www.cnblogs.com/andy9468/p/10444457.html
Windows: 在 Windows 中: 双击运行 Python 程序, 后台运行 Python 程序 https://www.cnblogs.com/andy9468/p/9676719.html
(二)python 语法
1, 数据类型
Python 的八种数据类型
八种数据类型分别是:
- number(数字),string(字符串),Boolean(布尔值),None(空值),
- list(列表),tuple(元组),dict(字典),set(集合).
编辑本文
2, 数据操作(方法)
(2)string(字符串)操作方法
- )len(s) # 获取字符串长度
- )s.strip("*") # 去除 s 两端的 * 号, 默认去除空格
- )s.split(",") # 按照, 号分割字符串 s 为 list
- )s.splitlines() # 按照行 (\n,\r\n,\r) 分割字符串 s 为 list
- )"@".join(list1) # 用 @号, 将 list1 中的元素连接成字符串
- )s.replace(oldstr, newstr, count) # 在 s 字符串中, 用 newstr 替换 oldstr, 共替换 count 次
- )s.startswith(s0) # 判断 s 字符串中是否是 s0 字串开始的
- )s.endswith(sn) # 判断 s 字串中是否是 sn 字串结尾的
- )s.encode("utf-8") # 将 s 字串按照 utf-8 格式编码为二进制流
- )b.decode("utf-8") # 将 b 二进制流按照 utf-8 解码为 s 字符串
- (4)None(空值)
空值 None 是 python 里一个特殊的值.
None 不能理解为 0, 因为 0 是有意义的, 而 None 是一个特殊值.
3,python 理论特点
4, 函数
5, 类
6, 框架, 系统
7, 多任务
8, 装饰器
9, 迭代器, 生成器
来源: http://www.bubuko.com/infodetail-3210578.html