sys模块:
1. sys.argv() #命令行参数list,第一个参数是程序的本身路径
test.py
import sys
print(sys.argv)
>> python test.py 11212 11212,1211as
['test.py', '11212', '11212,1211as']
2. sys.exit(n) #退出程序,正常退出时exit(0)
3. sys.version #解释器的版本
>>> sys.version
'3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]'
4. sys.path #模块的path环境变量
>>> sys.path
['', 'D:\Python3\python_project\Project_1\venv\Scripts\python36.zip', 'C:\Users\brace.li\AppData\Local\Programs
Python\Python36-32\DLLs', 'C:\Users\brace.li\AppData\Local\Programs\Python\Python36-32\lib', 'C:\Users\brace.l
i\AppData\Local\Programs\Python\Python36-32', 'D:\Python3\python_project\Project_1\venv', 'D:\Python3\python_pro
ject\Project_1\venv\lib\site-packages', 'D:\Python3\python_project\Project_1\venv\lib\site-packages\setuptools-3
9.0.1-py3.6.egg', 'D:\Python3\python_project\Project_1\venv\lib\site-packages\pip-9.0.3-py3.6.egg']
1. sys.argv() #命令行参数list,第一个参数是程序的本身路径
test.py
import sys
print(sys.argv)
>> python test.py 11212 11212,1211as
['test.py', '11212', '11212,1211as']
2. sys.exit(n) #退出程序,正常退出时exit(0)
3. sys.version #解释器的版本
>>> sys.version
'3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]'
4. sys.path #模块的path环境变量
>>> sys.path
['', 'D:\Python3\python_project\Project_1\venv\Scripts\python36.zip', 'C:\Users\brace.li\AppData\Local\Programs
Python\Python36-32\DLLs', 'C:\Users\brace.li\AppData\Local\Programs\Python\Python36-32\lib', 'C:\Users\brace.l
i\AppData\Local\Programs\Python\Python36-32', 'D:\Python3\python_project\Project_1\venv', 'D:\Python3\python_pro
ject\Project_1\venv\lib\site-packages', 'D:\Python3\python_project\Project_1\venv\lib\site-packages\setuptools-3
9.0.1-py3.6.egg', 'D:\Python3\python_project\Project_1\venv\lib\site-packages\pip-9.0.3-py3.6.egg']
5. sys.platform #返回系统平台
>>> sys.platform
'win32'
6. sys.stdout.write("ss") #标准输出
进度条的使用:
import sys,time
for i in range(100):
sys.stdout.write("#")
sys.stdout.flush()
time.sleep(0.1)
>>> sys.platform
'win32'
6. sys.stdout.write("ss") #标准输出
进度条的使用:
import sys,time
for i in range(100):
sys.stdout.write("#")
sys.stdout.flush()
time.sleep(0.1)