Python执行shell命令方法

2025-05-15 10:20:41

1、系统和python版本CentOS Linux release 7.5.1804 (Core)[root@node02-97 ~]# python -VPython 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命令方法
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢