У вас большие запросы!
Точнее, от вашего браузера их поступает слишком много, и сервер VK забил тревогу.
Эта страница была загружена по HTTP, вместо безопасного HTTPS, а значит телепортации обратно не будет.
Обратитесь в поддержку сервиса.
Вы отключили сохранение Cookies, а они нужны, чтобы решить проблему.
Почему-то страница не получила всех данных, а без них она не работает.
Обратитесь в поддержку сервиса.
Вы вернётесь на предыдущую страницу через 5 секунд.
Вернуться назад
У вас большие запросы!
Точнее, от вашего браузера их поступает слишком много, и сервер VK забил тревогу.
Эта страница была загружена по HTTP, вместо безопасного HTTPS, а значит телепортации обратно не будет.
Обратитесь в поддержку сервиса.
Вы отключили сохранение Cookies, а они нужны, чтобы решить проблему.
Почему-то страница не получила всех данных, а без них она не работает.
Обратитесь в поддержку сервиса.
Вы вернётесь на предыдущую страницу через 5 секунд.
Вернуться назад
У вас большие запросы!
Точнее, от вашего браузера их поступает слишком много, и сервер VK забил тревогу.
Эта страница была загружена по HTTP, вместо безопасного HTTPS, а значит телепортации обратно не будет.
Обратитесь в поддержку сервиса.
Вы отключили сохранение Cookies, а они нужны, чтобы решить проблему.
Почему-то страница не получила всех данных, а без них она не работает.
Обратитесь в поддержку сервиса.
Вы вернётесь на предыдущую страницу через 5 секунд.
Вернуться назад
Open a text file using notepad as a help file in python?
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 little blue help link on my GUI that could be clicked at any time resulting in a .txt file being opened in a native text editor, notepad for example. Is there a simple way of doing this?
27.6k 22 22 gold badges 122 122 silver badges 151 151 bronze badges
asked May 30, 2011 at 15:29
5,605 8 8 gold badges 42 42 silver badges 67 67 bronze badges
What’s the Gui framework you’re using (PyGtk, Tkinter, . )?!
May 30, 2011 at 15:34
@ThomasH: From the OP’s other questions, it looks like he’s using the PyQt application framework.
Jun 1, 2011 at 12:53
7 Answers 7
import webbrowser webbrowser.open("file.txt")
Despite it’s name it will open in Notepad, gedit and so on. Never tried it but it’s said it works.
An alternative is to use
osCommandString = "notepad.exe file.txt" os.system(osCommandString)
or as subprocess:
import subprocess as sp programName = "notepad.exe" fileName = "file.txt" sp.Popen([programName, fileName])
but both these latter cases you will need to find the native text editor for the given operating system first.
answered May 30, 2011 at 15:35
Máthé Endre-Botond Máthé Endre-Botond
4,836 2 2 gold badges 29 29 silver badges 48 48 bronze badges
+1 for the creativity of thinking of browser . I would also suggest looking at this question on SO
May 30, 2011 at 16:07
Note that using os.system() is discouraged now for security reasons.
Jan 25, 2014 at 5:45
According to the webbrowser documentation: «Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program. However, this is neither supported nor portable.» So this probably works on Unix, but may not work on Windows.
Jun 2, 2017 at 20:55
@AdamStewart I am on Mac and it silently does nothing for me.
May 22, 2020 at 12:14
Webbrowser does not work on Windows 10 with VSCode.
Dec 29, 2020 at 18:29
os.startfile('file.txt')
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.
answered Jan 25, 2014 at 5:43
4,128 5 5 gold badges 31 31 silver badges 49 49 bronze badges
This is a good approach, but it is only available on Windows. In a unix environment, you are probably best off using os.system(‘$EDITOR
Dec 28, 2016 at 21:05
You can do this in one line:
import subprocess subprocess.call(['notepad.exe', 'file.txt'])
You can rename notepad.exe to the editor of your choice.