Python suprocess.run() 对于 Windows

Python suprocess.run() for Windows

我创建了一个 png 文件并在 macOS 上使用

查看它
[...]
image.save("mandel.png", "PNG")
p = subprocess.run(["open", "mandel.png"], capture_output=True)
print(p.stdout.decode(),p.stderr.decode())

但是windows我有什么选择呢? “打开”在 Win10 上不起作用。

[...]
image.save("mandel.png", "PNG")
p = subprocess.run(["start", "mandel.png"], capture_output=True)
print(p.stdout.decode(),p.stderr.decode())

您可以在windows中使用start命令。

参考:

http://www.frankworsley.com/blog/2007/9/24/open-a-file-in-the-default-application-using-the-windows-command-line-without-jdic