python基础之模块之sys模块

sys模块的功能

sys是python中较为常用的一个模块,他提供了对python脚本运行时的环境的操作。

sys功能:

1  sys.argv     #将python脚本运行时的脚本名以及参数作为一个list,并输出。

 View Code

2  sys.path    #返回一个list,该list为当前脚本的path环境变量(PYTHONPATH)

 View Code

  如果我们要增加或者删除pythonpath的话,使用list的insert或者pop功能即可。

 View Code

3  sys.platform   #返回当前平台

 View Code

4  sys.stdout   sys.stdin   #标准输出/输入

 View Code

 5  sys.stderr   #错误输出

使用方法同上

原文地址:https://www.cnblogs.com/yezuhui/p/6860390.html