所以我有这个可执行的二进制文件,可以通过终端运行
并通过python
使用代码
$`python3 shell_c.py`
其中python文件包含
import subprocess
def executable_shell():
x=subprocess.run('cd build && ./COSMO/methane_c0.outmol.cosmo', shell=True, capture_output=True)
print(x)
executable_shell()
其中COSMO是我的可执行文件名,“chmate_c0.outmol”是应随扩展名“.COSMO”一起更改的动态值)
为了从JSON文件中获取这些值,我创建了一个JSON文件 投入
{
"root_directory": "C:\\Users\\15182\\cosmo theory\\COSMO\\UDbase8",
"file_name": "methane_c0",
"file_format": ".cosmo",
"output1": "N_atoms",
"output2": "total number of segments"
}
现在剩下的就是将file_name和file_format的值传递给子流程代码以运行它。 但我不知道该怎么做
到目前为止,我编写的代码是基本的
import json
with open ("parameters.json") as file:
data =json.load(file)
print(type(data))
pront(data)
如何将值传递给python文件
像这样的
相关问题 更多 >
编程相关推荐