本节内容
- 模块初识
- .pyc简介
- 数据类型初识
- 数据运算
- 列表、元组操作
- 字符串操作
- 字典操作
- 集合操作
- 字符编码与转码
一、模块初识
Python的强大之处在于他有非常丰富和强大的标准库和第三方库,几乎你想实现的任何功能都有相应的Python库支持,让我们先来象征性的学2个简单的。
sys
1 #!/usr/bin/env python 2 3 # -*- coding: utf-8 -*- 4 5 6 7 import sys 8 9 10 11 print(sys.argv) 12 13 14 15 16 17 #输出 18 19 $ python test.py helo world 20 21 ['test.py', 'helo', 'world'] #把执行脚本时传递的参数获取到了
os
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import os
5
6 os.system("df -h") #调用系统命令