方法一:os.popen
#!/usr/bin/python
# -*- coding: UTF-8 -*- import os, sys # 使用 mkdir 命令
a = 'ls' b = os.popen(a,'w',1) print b
方法二:os.system
#!/usr/bin/python
# -*- coding: UTF-8 -*- import os, sys arg0="121.429015"
arg1="31.245255" os.system('sh trans.sh '+arg0+' '+arg1)
其中trans.sh代码:
echo $1 $2
方法三:subprocess
import subprocess
returnCode = subprocess.call('pwd')
print returnCode
方法四:commands
import commands
result=commands.getoutput('pwd')
result1=commands.getstatusoutput('pwd')
print result
print result1