2024-06-16 17:20:39 发布
网友
我使用的是Unix操作系统,我想知道如何执行一个命令,该命令可以从Python脚本中的其他软件执行。 我在我的系统中安装了一个名为HAL Tools的软件,它有一个名为maf2hal的命令,其中包含两个参数,即输入和输出文件。命令的路径保存在my.bash\u profile的path变量下。我同样从UNIX调用命令:
[root ~]$ maf2hal inputfile outputfile
我想从Python脚本调用这个命令。我需要使用的语句或函数是什么
1.使用os.popen()执行命令:
import os os.popen("maf2hal inputfile outputfile")
2.subprocess.call()
from subprocess import call call("maf2hal inputfile outputfile", shell=True)
你可以看看^{}
示例命令可以是
import os os.system('maf2hal inputfile outputfile')
1.使用os.popen()执行命令:
2.subprocess.call()
你可以看看^{}
示例命令可以是
相关问题 更多 >
编程相关推荐