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

后端 未结 6 1950
攒了一身酷
攒了一身酷 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:47

    os.startfile('file.txt')
    

    From the python docs:

    this acts like double clicking the file in Windows Explorer, or giving the file name as an argument to the start command from the interactive command shell: the file is opened with whatever application (if any) its extension is associated.

    This way if your user changed their default text editor to, for example, notepad++ it would use their preference instead of notepad.

提交回复
热议问题