本节内容

  1. 模块初识
  2. .pyc简介
  3. 数据类型初识
  4. 数据运算
  5. 列表、元组操作
  6. 字符串操作
  7. 字典操作
  8. 集合操作
  9. 字符编码与转码

一、模块初识

    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']  #把执行脚本时传递的参数获取到了
View Code

     os      

    
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 import os
5 
6 os.system("df -h") #调用系统命令
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案