本文介绍了相当于Windows中双击的Python子进程模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用subprocess
模块打开文件,就像在资源管理器中双击该文件一样.我该怎么办?
I want to open a file using the subprocess
module as though the file was double-clicked in Explorer. How do I do that?
我尝试了以下行:
subprocess.call("C:/myfile.csv", shell=True)
抛出错误:
如何使用subprocess
模拟双击?基本上,我想在Excel 2007中打开CSV文件.
How do I emulate a double-click using subprocess
? Basically I want to open a CSV file in Excel 2007.
推荐答案
os.startfile(r'C:\myfile.csv')
(仅Win32.对于Mac,使用'open filename'
;在Linux/freedesktop-in-general的'xdg-open filename'
上运行一个进程.)
(Win32 only. For Mac, run a process with 'open filename'
; on Linux/freedesktop-in-general, 'xdg-open filename'
.)
这篇关于相当于Windows中双击的Python子进程模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!