#系统自带的模块 import sys print(sys.path)#打印环境变量 print(sys.argv)#打印绝对路径 import os #cmd_res = os.system("dir")#打印系统目录 cmd_res = os.popen("dir").read() print(cmd_res) import Day2#可直接调用其他模块,默认找当前目录下,之后就是环境变量,如果在其他目录下,把之前要导入的放在site_package下
#bytes类型编码互转 name = "我爱我家" print(name.encode("utf-8")) print(name.encode(encoding='utf-8').decode(encoding='utf-8')) home = "shanghai,shenzhen,hangzhou" print(home.encode("utf-8")
输出结果
F:pypyProjectvenvScriptspython.exe F:/py/pyProject/venv/sys_os.py ['F:\py\pyProject\venv', 'F:\py\pyProject', 'F:\py\pyProject\venv\Scripts\python37.zip', 'F:\pytools\DLLs', 'F:\pytools\lib', 'F:\pytools', 'F:\py\pyProject\venv', 'F:\py\pyProject\venv\lib\site-packages', 'F:\py\pyProject\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg', 'F:\py\pyProject\venv\lib\site-packages\pip-10.0.1-py3.7.egg', 'F:\pycharm install\PyCharm 2018.2.3\helpers\pycharm_matplotlib_backend'] ['F:/py/pyProject/venv/sys_os.py'] 驱动器 F 中的卷没有标签。 卷的序列号是 014C-014D F:pypyProjectvenv 的目录 2018/09/15 17:21 <DIR> . 2018/09/15 17:21 <DIR> .. 2018/09/15 17:21 <DIR> Include 2018/09/15 17:21 <DIR> Lib 2018/09/15 17:21 <DIR> Scripts 2018/09/15 17:21 74 pyvenv.cfg 2018/09/17 18:24 <DIR> new_page 2018/09/19 16:51 572 sys_os.py 2018/09/16 20:01 553 while.py 3 个文件 1,199 字节 6 个目录 61,125,836,800 可用字节 b'xe6x88x91xe7x88xb1xe6x88x91xe5xaexb6' 我爱我家 b'shanghai,shenzhen,hangzhou'