1,通过os获取系统类型
import os
print(os.name)
windows系统,os.name = 'nt',
linux系统os.name = 'posix'
2,执行系统命令
import os
os.system(‘ipconfig’)
content=os.popen('ipconfig').read()
print(content)
解释:
该代码调用了windows系统的ipconfig命令,ipconfig
1,通过os获取系统类型
import os
print(os.name)
windows系统,os.name = 'nt',
linux系统os.name = 'posix'
2,执行系统命令
import os
os.system(‘ipconfig’)
content=os.popen('ipconfig').read()
print(content)
解释:
该代码调用了windows系统的ipconfig命令,ipconfig