Open a text file using notepad as a help file in python?

后端 未结 6 1948
攒了一身酷
攒了一身酷 2020-11-29 08:28

I would like to give users of my simple program the opportunity to open a help file to instruct them on how to fully utilize my program. Ideally i would like to have a littl

6条回答
  •  星月不相逢
    2020-11-29 08:44

    If you have any preferred editor, you can just first try opening in that editor or else open in a default editor.

    ret_val = os.system("gedit %s" % file_path)
    if ret_val != 0:
        webbrowswer.open(file_path)
    

    In the above code, I am first trying to open my file in gedit editor which is my preferred editor, if the system does not have gedit installed, it just opens the file in the system's default editor.

提交回复
热议问题