answer727

方法一: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

 

分类:

技术点:

相关文章:

  • 2021-06-21
  • 2022-03-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-05-16
猜你喜欢
  • 2021-11-19
  • 2022-02-15
  • 2021-04-08
  • 2021-11-19
  • 2021-12-06
相关资源
相似解决方案