Python执行shell命令方法

 时间:2026-04-30 02:06:34

1、系统和python版本

CentOS Linux release 7.5.1804 (Core) 

[root@node02-97 ~]# python -V

Python 2.7.5

Python执行shell命令方法

2、os.system("pwd") 

Python执行shell命令方法

3、os.popen('pwd','r')

Python执行shell命令方法

4、commands.getstatusoutput('ls')

Python执行shell命令方法

5、subprocess.call(['ls','-l'],shell=True)

Python执行shell命令方法

6、subprocess.check_output(["echo","hello world!"])

Python执行shell命令方法

7、os.spawnv(os.P_NOWAIT, 'ls', '-l') 

Python执行shell命令方法

  • Centos 安装cmake 方法
  • linux系统怎么安装jdk和配置环境变量
  • 如何下载安装VisualC++6.0?
  • phpMyAdmin尝试连接到MySQL服务器错误怎么办
  • python怎么从3.7降到3.6版本
  • 热门搜索
    疏怎么组词 福特车怎么样 戴尔笔记本电脑怎么样 蚜虫怎么防治 缺铁性贫血怎么治疗 离职后五险一金怎么办 怎么哄老婆开心 怀孕一个月怎么办 怎么变高冷 孕妇牙痛怎么办