Opening pdf file

后端 未结 5 1097
迷失自我
迷失自我 2020-12-30 22:55

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 al

相关标签:
5条回答
  • 2020-12-30 23:06
    import os
    os.startfile(filename)
    
    0 讨论(0)
  • 2020-12-30 23:07

    Try:

    subprocess.Popen([file],shell=True)
    
    0 讨论(0)
  • 2020-12-30 23:10

    This is a bit late but nobody mentioned:

    open("file_name.pdf")
    
    0 讨论(0)
  • 2020-12-30 23:15
    import webbrowser
    webbrowser.open_new(r'file://C:\path\to\file.pdf')
    
    0 讨论(0)
  • 2020-12-30 23:27

    Read the documentation thoroughly. The very first line of the os.system method is:

    Execute the command (a string) in a subshell.

    Knowing this, you can now seek alternate solutions, such as the subprocess module already mentioned.

    0 讨论(0)
提交回复
热议问题