Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.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
Python 3.x 如何更改默认程序以在Python中打开文件?_Python 3.x_Stl - Fatal编程技术网

Python 3.x 如何更改默认程序以在Python中打开文件?

Python 3.x 如何更改默认程序以在Python中打开文件?,python-3.x,stl,Python 3.x,Stl,我正在使用os.startfile(path\file.stl)打开一个stl文件。默认情况下,STL文件在程序Print 3D(使用Windows 10)中打开。我希望Python程序不要在默认程序中打开STL文件,而是在Paint 3D(或我选择的其他STL查看程序)中打开。如何在非默认程序中打开文件 import os os.startfile(r'C:\Users\my\path\to\file.stl') #opens file.stl in default program, not

我正在使用os.startfile(path\file.stl)打开一个stl文件。默认情况下,STL文件在程序Print 3D(使用Windows 10)中打开。我希望Python程序不要在默认程序中打开STL文件,而是在Paint 3D(或我选择的其他STL查看程序)中打开。如何在非默认程序中打开文件

import os
os.startfile(r'C:\Users\my\path\to\file.stl')
#opens file.stl in default program, not the program I would like
建议没有办法做到这一点(至少在
os.startfile
中没有办法)

该文件将使用与其扩展名关联的任何应用程序(如果有)打开


除了os.startfile之外,您还知道其他方法吗?