Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用SubAccess库使用python打开新的Powerpoint文件?_Python_Python 3.x_Python Requests_Subprocess_Powerpoint - Fatal编程技术网

如何使用SubAccess库使用python打开新的Powerpoint文件?

如何使用SubAccess库使用python打开新的Powerpoint文件?,python,python-3.x,python-requests,subprocess,powerpoint,Python,Python 3.x,Python Requests,Subprocess,Powerpoint,尽管我到处搜索,但对于如何使用子流程库打开新的Powerpoint文件,我找不到合适的答案。 我已经查找了office.exe文件名,该文件名显示它是powerpnt.exe 我试过了,但是在subprocess.call:subprocess.call([“powerpnt.exe]”)中,powerpoint.exe 我还尝试了subprocess.Popen(“start powerpnt.exe,shell=True)和subprocess.run() .当然,我还尝试了子流程的其他选项

尽管我到处搜索,但对于如何使用子流程库打开新的Powerpoint文件,我找不到合适的答案。 我已经查找了office.exe文件名,该文件名显示它是
powerpnt.exe
我试过了,但是在subprocess.call:
subprocess.call([“powerpnt.exe]”)中,
powerpoint.exe
我还尝试了
subprocess.Popen(“start powerpnt.exe,shell=True)
subprocess.run()
.当然,我还尝试了子流程的其他选项,但都失败了

我可以使用Subprocess通过Subprocess.call([“write.exe])
(而不是Word.exe)打开Microsoft Word。 Iam能够使用以下代码打开带有子流程的现有word文件:
subprocess.run([“write.exe”,app\u name])
但是我发现没有任何关于打开一个现有的\新的带有subprocess的PP的方法。有人能帮我吗

另外,在使用子流程时,是否有关于.exe文件\ micorosft文件后缀的文档

我的总体代码非常简单:

import errno
import os
import subprocess

def m_open(path):
    try:
       subprocess.run(["POWERPNT.exe",path]) # call the powerpoint\the file
    except OSError as e:
        if e.errno == errno.ENOENT:
            print("So this app doesn't exist...") # handle file not found error.
        else:
            raise #Something else went wrong while trying to run the program\file

if __ name__ == "__ main__":
    m_open('C://def/work.pptx')

在您的代码
app\u name
中未定义您的参数“path”未使用,而是在子流程调用中使用了“app\u name”。这是一个拼写错误吗?哦,为了提问,我更改了它。在我的代码中(在所有方面都很相似,但没有拼写错误)。