1.使用os.system()
import os cmd = 'put your command here' os.system(cmd)
2.使用os.popen()
import os cmd = 'put your command here' result = os.popen(cmd).read() print(result)
区别:
os.system()执行指令无回显,不能判断指令执行结果
os.popen()带有返回值,包含指令执行结果
1.使用os.system()
import os cmd = 'put your command here' os.system(cmd)
2.使用os.popen()
import os cmd = 'put your command here' result = os.popen(cmd).read() print(result)
区别:
os.system()执行指令无回显,不能判断指令执行结果
os.popen()带有返回值,包含指令执行结果