如何使用Python启动应用程序的实例? [英] How can I launch an instance of an application using Python?
本文介绍了如何使用Python启动应用程序的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个Python脚本,其中执行了许多任务,其中一个任务是启动并打开Excel实例.在我的脚本中完成此操作的理想方法是什么?
I am creating a Python script where it does a bunch of tasks and one of those tasks is to launch and open an instance of Excel. What is the ideal way of accomplishing that in my script?
推荐答案
虽然Popen
答案对于一般情况是合理的,但如果您想对它进行一些有用的操作,我建议在这种情况下使用win32api
:
While the Popen
answers are reasonable for the general case, I would recommend win32api
for this specific case, if you want to do something useful with it:
它是这样的:
from win32com.client import Dispatch
xl = Dispatch('Excel.Application')
wb = xl.Workbooks.Open('C:\\Documents and Settings\\GradeBook.xls')
xl.Visible = True # optional: if you want to see the spreadsheet
来自邮件列表帖子,但周围有很多例子.
Taken from a mailing list post but there are plenty of examples around.
这篇关于如何使用Python启动应用程序的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文