标签:arm zip otl day 命令行 files hang ken bit
所有和python解释器相关的都在sys模块
mport sys print(sys.path) 结果: [‘E:\\python_个人\\day 023 re模块‘, ‘E:\\python_个人‘, ‘C:\\Python36\\python36.zip‘, ‘C:\\Python36\\DLLs‘, ‘C:\\Python36\\lib‘, ‘C:\\Python36‘, ‘C:\\Python36\\lib\\site-packages‘, ‘E:\\Program Files\\JetBrains\\PyCharm 2018.2.4\\helpers\\pycharm_matplotlib_backend‘]
由返回结果可知,返回的是列表,由此,可通过append方法手动增加搜索路径
import sys sys.path.append("e:/") print(sys.path) # 结果: [‘E:\\python_个人\\day 023 re模块‘, ‘E:\\python_个人‘, ‘C:\\Python36\\python36.zip‘, ‘C:\\Python36\\DLLs‘, ‘C:\\Python36\\lib‘, ‘C:\\Python36‘, ‘C:\\Python36\\lib\\site-packages‘, ‘E:\\Program Files\\JetBrains\\PyCharm 2018.2.4\\helpers\\pycharm_matplotlib_backend‘, ‘e:/‘]
如:在E盘下新建test.py文件,文件里写入import sys/print(sys.argv)内容,在cmd下,运行test.py zhang li,则列表里接收到zhang li参数
import sys print(sys.version) # 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)]
import sys print(sys.platform) # win32
标签:arm zip otl day 命令行 files hang ken bit
原文地址:https://www.cnblogs.com/ipython-201806/p/9957947.html