我正在尝试运行abaqus inp文件,并使用来自python的abaqus对其进行处理并获取输出。它不起作用。怎么做?
import os
import subprocess
inp = 'C:/Users/sel/Desktop/My work/Python Abaqus/New folder (2)/Job-1.inp'
abaqus = r'C:/SIMULIA/Abaqus/Commands/abq6145.bat'
subprocess.Popen("%s %s" % (abaqus, inp))
您可以通过将run
关键字参数设置为capture_output
,通过子流程模块的True
功能来捕获子流程的stdout和strerr。这应该可以。
inp = 'C:/Users/sel/Desktop/My work/Python Abaqus/New folder (2)/Job-1.inp'
abaqus = r'C:/SIMULIA/Abaqus/Commands/abq6145.bat'
cp = subprocess.run([abaqus, inp], capture_output=True)
cp.stdout