zoukankan      html  css  js  c++  java
  • 第二周第二节模块初识

    块:别人写好的功能封装成一个名字,网上下载下来,导入后直接用,不用再写了
    第三方库:下载下来安装上才能用
    两个标准库:sys os
    sys模块

    import sys
    print(sys.path) //打印环境变量
    

      

    "C:Usersgoogle WANGAppDataLocalProgramsPythonPython36python.exe" D:/projects/sys.py
    ['D:\projects', 'D:\projects', 'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\python36.zip', 'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\DLLs', 'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\lib', 'C:\Users\google WANG\AppData\Local\Programs\Python\Python36', 'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\lib\site-packages', 'C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\pycharm_matplotlib_backend']

    Process finished with exit code 0


    "C:Usersgoogle WANGAppDataLocalProgramsPythonPython36python.exe" D:/projects/sys_mode.py
    ['D:\projects', 'D:\projects', 'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\python36.zip',
    'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\DLLs',
    'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\lib', 、//一般标准库放在这里面
    'C:\Users\google WANG\AppData\Local\Programs\Python\Python36',
    'C:\Users\google WANG\AppData\Local\Programs\Python\Python36\lib\site-packages', //自己装的放在这里面
    'C:\Program Files\JetBrains\PyCharm 2018.3.5\helpers\pycharm_matplotlib_backend']

    Process finished with exit code 0
    系统有环境变量
    prthon也有环境变量

    打印脚本的绝对路径 ,因为pycharm就是绝对路径,所以打印的是绝对路径

    import sys
    print(sys.argv)
    输出结果:
    "C:Usersgoogle WANGAppDataLocalProgramsPythonPython36python.exe" D:/projects/sys_mode.py
    ['D:/projects/sys_mode.py']
    

      

    windows下dir是查看路径的

    import os
    os.system ("dir") //直接输出到屏幕上
    
     
    
    "C:Usersgoogle WANGAppDataLocalProgramsPythonPython36python.exe" D:/projects/sys_mode.py
    ������ D �еľ��� �¼Ӿ�
    �������� A45A-FDF2
    
    D:projects ��Ŀ¼
    
    2019/04/08 19:06 <DIR> .
    2019/04/08 19:06 <DIR> ..
    2019/04/08 19:04 <DIR> .idea
    2019/04/07 14:42 110 for+contiune.py
    2019/04/07 14:16 42 Forѭ��.py
    2019/04/07 14:22 308 forѭ����else.py
    2019/04/07 14:49 123 forѭ��Ƕ��.py
    2019/04/08 19:06 88 sys_mode.py
    2019/04/07 11:08 197 test.py
    2019/04/07 11:33 301 while+if else.py
    2019/04/07 11:20 65 while.py
    2019/04/07 11:35 273 while����if.py
    2019/04/07 14:31 406 while������.py
    2019/04/07 11:41 327 while�Դ�3����ʾ.py
    11 ���ļ� 2,240 �ֽ�
    3 ��Ŀ¼ 10,968,879,104 �����ֽ�
    
    Process finished with exit code 0
    
     
    

      

    import os
    cmd_res=os.system ("dir") #执行命令,不保存结果
    print("------->",cmd_res)
    
    输出结果:
    -------> 0 //0代表命令执行的状态码,0代表执行成功,非0代表错误
    

      

    import os
    cmd_res=os.popen ("dir") #执行命令,不保存结果
    print("------->",cmd_res)
    
    输出结果:-------> <os._wrap_close object at 0x000001F93B0DC898> 打印的内存对象的值
    

      

    import os
    cmd_res=os.popen ("dir").read() #后面加read就把结果读出来了
    print("------->",cmd_res)
    输出结果:
    
    
    -------> 驱动器 D 中的卷是 新加卷
    卷的序列号是 A45A-FDF2
    
    D:projects 的目录
    
    2019/04/08 19:16 <DIR> .
    2019/04/08 19:16 <DIR> ..
    2019/04/08 19:15 <DIR> .idea
    2019/04/07 14:42 110 for+contiune.py
    2019/04/07 14:16 42 For循环.py
    2019/04/07 14:22 308 for循环加else.py
    2019/04/07 14:49 123 for循环嵌套.py
    2019/04/08 19:16 207 sys_mode.py
    2019/04/07 11:08 197 test.py
    2019/04/07 11:33 301 while+if else.py
    2019/04/07 11:20 65 while.py
    2019/04/07 11:35 273 while不加if.py
    2019/04/07 14:31 406 while任意玩.py
    2019/04/07 11:41 327 while试错3次提示.py
    11 个文件 2,359 字节
    3 个目录 10,969,739,264 可用字节
    

      












    import os
    cmd_res=os.popen ("dir").read()
    print("------->",cmd_res)
    os.mkdir("new_dir") //执行后创建一个新的目录
    

      

  • 相关阅读:
    MidPayinfoVO
    IPayablebillItf
    预算oracle
    oracle怎么查看表字段的类型
    orcale授权
    ORCAL
    【转】Oracle
    其他网站api
    生成pdf入门
    有关一个java项目到eclipse中运行
  • 原文地址:https://www.cnblogs.com/googlewang/p/10704465.html
Copyright © 2011-2022 走看看