python - 如何与子进程交互和使用应用程序的属性
问题描述
我一直在尝试使用“子进程”包从 python 访问 Microsoft Print 3D。
我想要做的是在应用程序中打开一组(.stl)文件并从每个文件中提取一些信息。
#Path of the program
MS_Print_3D = '... /Applications (Parallels)/{c2916d26-d1f5-414d-b261-d6c91024400d} Applications.localized//Print 3D.app'
#STL 3D file
stl_file = '.../994012.stl'
我必须使用选定的(.stl)文件打开并运行程序。但是,我不知道如何访问应用程序内绘制的属性或信息。
p_run = subprocess.run(["open", "-n", MS_Print_3D, stl_file],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
text=True,
)
我使用 stdout 来查看是否有输出。但是我真正想知道的是我是否可以访问我正在使用子进程打开的应用程序、软件或程序中的信息。
我只是想知道这是否可能,或者我是否应该使用另一种方法。
print('Standard Output:', p_run.stdout)
print('-------------')
print('Standard Error:', p_run.stderr)
print('-------------')
print('Arguments:', p_run.args)
print('-------------')
print('Return Code:', p_run.returncode)
print('-------------')
print('Check Return Code:', p_run.check_returncode)
print('-------------')
Standard Output:
-------------
Standard Error:
-------------
Arguments: ['open', '-n', '.../Applications (Parallels)/{c2916d26-d1f5-414d-b261-d6c91024400d} Applications.localized//Print 3D.app', '.../994012.stl']
-------------
Return Code: 0
-------------
Check Return Code: <bound method CompletedProcess.check_returncode of CompletedProcess(args=['open', '-n', '... Applications (Parallels)/{c2916d26-d1f5-414d-b261-d6c91024400d} Applications.localized//Print 3D.app', '...//994012.stl'], returncode=0, stdout='', stderr='')>
-------------
解决方案
推荐阅读
- java - Java Spring Pagination的问题,有些页面是空的
- r - 替换R中的复杂正则表达式
- python - 如何让 HoloViews 框选择工具同步多个连接的图?
- oracle - Oracle APEX 5.0 多个空格在 IR 中显示为单个空格
- typescript - Firebase 函数:TypeError:functions.https.HttpsError 不是构造函数
- excel - 从 excel 复制数据,并将其附加到现有的 txt 文件中
- javascript - 带有反应原生的移动箭头
- dataframe - 按组汇总的 Juila 数据框汇总(又名小计)
- android - Flutter 在 VSCode 中为 android 添加圆形应用图标
- c - 如何将库 libbson 1.9.5 添加到 Visual Studio?