python小白-day5 sys模块

sys模块

1
2
3
4
5
6
7
8
sys.argv           命令行参数List,第一个元素是程序本身路径
sys.exit(n)        退出程序,正常退出时exit(0)
sys.version        获取Python解释程序的版本信息
sys.maxint         最大的Int
sys.path           返回模块的搜索路径,初始化时使用PYTHONPATH环境变量的值
sys.platform       返回操作系统平台名称
sys.stdout.write('please:')
val = sys.stdin.readline()[:-1]
例子:​

1
2
3
4
5
6
7
8
9
import sys
import time
for i in range(10):
    sys.stdout.write('#')
    sys.stdout.flush()
    time.sleep(0.3)
print(sys.version)
print(sys.path)
print(sys.platform)








原文地址:https://www.cnblogs.com/hetan/p/5184994.html