Trying to use xdg-open in a python script
xdg-open test.mp4
but get the following error:
File "dl.py", line 21
xdg-open test.mp4
^
SyntaxError: invalid syntax
I can do it from command line so there is no issue with mp4
Trying to use xdg-open in a python script
xdg-open test.mp4
but get the following error:
File "dl.py", line 21
xdg-open test.mp4
^
SyntaxError: invalid syntax
I can do it from command line so there is no issue with mp4
I don't have enough reputation for a comment, but since no one else is replying I try to give an answer. I don't remember about 2.7 but in Python 3 I normally use something like this:
os.system("xdg-open "+ <string>)
os.system is a command also in Python 2.7. You have to import os first. Hope it helps ;-)
This works on Linux, it will open the requested file with the appropriate software.
Use code below:
import subprocess
subprocess.call(["xdg-open", "filename"])