Python xdg-open() [英] Python xdg-open()

查看:60
本文介绍了Python xdg-open()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 python 脚本中使用 xdg-open

Trying to use xdg-open in a python script

xdg-open test.mp4

但得到以下错误:

File "dl.py", line 21
    xdg-open test.mp4
                ^
SyntaxError: invalid syntax

我可以从命令行执行此操作,因此 mp4 没有问题

I can do it from command line so there is no issue with mp4

推荐答案

这适用于 Linux,它将使用适当的软件打开请求的文件.

This works on Linux, it will open the requested file with the appropriate software.

使用以下代码:

import subprocess
subprocess.call(["xdg-open", "filename"])

这篇关于Python xdg-open()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆