smstars

使用os 模块及command模块的相关方法可以在python中调用linux shell命令。

1.os模块的system方法

os.system(cmd):此方法会创建子进程运行外部程序,方法只返回外部程序的运行结果;比较适用于外部程序没有输出结果的情况。

2.os模块的popen方法

os.popen(cmd):使用popen方法可以得到外部程序的输出结果,需要使用read( )得到命令输出内容。

3.commands模块的 getoutput方法

commands.getoutput( ):把输出结果当作字符串返回。

分类:

技术点:

相关文章:

  • 2021-11-20
  • 2022-01-02
  • 2022-01-02
  • 2021-12-21
  • 2021-12-31
  • 2021-11-05
  • 2021-12-15
  • 2021-11-08
猜你喜欢
  • 2021-11-19
  • 2021-12-21
  • 2021-10-17
  • 2022-01-02
  • 2021-12-21
  • 2021-12-31
  • 2021-06-18
相关资源
相似解决方案