Opening pdf file
Question:
I wanna open pdf file from python console, I can do it with os.system(filename)
, it will open in adobe reader, but the problem is that os.system
also opens a command prompt, is there another way that won’t open command prompt?
Answers:
Try:
import subprocess
subprocess.Popen([file],shell=True)
import webbrowser
webbrowser.open_new(r'file://C:pathtofile.pdf')
This is a bit late but nobody mentioned:
open("file_name.pdf")
import os
os.startfile(filename)
open("file_name.pdf")
This code is giving the following error for me.
(unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated UXXXXXXXX escape
I wanna open pdf file from python console, I can do it with os.system(filename)
, it will open in adobe reader, but the problem is that os.system
also opens a command prompt, is there another way that won’t open command prompt?
Try:
import subprocess
subprocess.Popen([file],shell=True)
import webbrowser
webbrowser.open_new(r'file://C:pathtofile.pdf')
This is a bit late but nobody mentioned:
open("file_name.pdf")
import os
os.startfile(filename)
open("file_name.pdf")
This code is giving the following error for me.
(unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated UXXXXXXXX escape