lonelyisland

使用os.system()和os.popen()

os.system()参数: 命令+参数, 参数可以看做是cmd命令 返回值是0--表示成功 1--表示失败
os.popen()参数: 参数也是cmd命令 返回值是一个对象obj,使用obj.read()可以读取其中存储的内容

test.py

import os

someCmd = "python hello.py"
mark1 = os.system(someCmd) #mark1 = 0,然后命令行会输出hello world
mark2 = os.popen(someCmd) #这里命令行没有输出
print(mark2.read()) #执行到这一句会输出 hello world

hello.py

print("hello world")

分类:

技术点:

相关文章:

  • 2021-12-28
  • 2021-06-24
  • 2021-06-23
  • 2021-12-06
  • 2021-05-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-12-11
  • 2021-12-02
  • 2021-12-06
  • 2021-12-06
  • 2021-12-06
相关资源
相似解决方案