B
B
buryakov_dima2015-12-23 20:49:13
Python
buryakov_dima, 2015-12-23 20:49:13

Python how to remove message when opening browser via webbrowser module?

Hello, there was a small problem with opening a new tab in the browser using python, there is the following code:

webbrowser.open_new(self.url)
self.code = raw_input("Code: ")

it opens a new tab in the browser with the given URL, and then asks for a code, but it turns out that after opening the tab in the browser, the message "A new window has been created in the current browser session" is displayed in the console. and it turns out that there is nowhere to enter the code, because in the place that the code should be entered there is this notification. What are the ways to remove it? Ps console application.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nirvimel, 2015-12-23
@buryakov_dima

If input from the console was requested, then the console will wait for input until Enter is pressed, and it does not matter what is being poured into the console from other threads at that moment. This is confusing, of course, but it doesn't affect input. You can safely continue typing, not paying attention to all this dirt, only what is entered from the keyboard will get into the input. But if you want to do it somehow more aesthetically, then you can wait for the output, pause, translate the line and read raw_input:

import time
webbrowser.open_new(self.url)
time.sleep(2)  # можете сами подобрать это значение
print("\n")
self.code = raw_input("Code: ")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question