
模块 –SYS
os模块是跟操作系统的交互
sys是跟python解释器的交互
sys.argv |
命令行参数List,第一个元素是程序本身路径 返回一个列表 |
In [218]: sys.argv Out[218]: ['C:\\Python35-32\\Scripts\\ipython'] |
sys.exit(n) |
exit(...) exit([status]) |
In [220]: sys.exit(0) |
sys. version |
显示版本 |
In [221]: sys.version |
sys.path |
python的环境变量列表 返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值 |
In [222]: sys.path 返回一个list |
sys.platform |
返回平台信息 |
In [223]: sys.platform Out[223]: 'win32' In [49]: sys.platform Out[49]: 'linux' |
ys.stdout.write("hhhh") |
在控制台显示消息 |
In [225]: sys.stdout.write("hhhh") hhhh In [226]: sys.stdout.flush() |
sys.stdin.readline() |
This class provides a character and line based interface to stream | I/O. There is no readinto method because Python's character strings | are immutable. There is no public constructor. |
sys.stdin.readline()会将标准的输入全部获取 |