import sys

# 把命令行参数返回一个 List,第一个元素是程序本身的路径
print(sys.argv)
# 命令行运行
python3 sys_model.py klvchen hello world
运行结果:
['sys_model.py', 'klvchen', 'hello', 'world']


# 返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值
print(sys.path)
运行结果:
['D:\\python_script\\alex_test\\day18', 'D:\\python_script\\alex_test', 'D:\\python35\\python35.zip', 'D:\\python35\\DLLs', 'D:\\python35\\lib', 'D:\\python35', 'D:\\python35\\lib\\site-packages']


# 返回操作系统平台名称
print(sys.platform)
运行结果:
win32

相关文章:

  • 2021-11-13
  • 2022-03-02
  • 2021-09-21
  • 2022-01-07
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2021-08-14
  • 2021-10-01
  • 2021-07-07
  • 2021-11-28
  • 2021-08-04
相关资源
相似解决方案