I am trying to open a webpage using Python, and my editor is VS Code.
This is the code:
import webbrowser
webbrowser.open('google.com')
This won't work while using VS Code, but it does work when I'm using IDLE.
What am I misunderstanding? What have I not done/done incorrectly? I have the Open in Browser extension by TechER, but even with this, I can't open a web browser page while using VS Code, and nothing I've found has been remotely helpful or even hints at what to do.
I'm clearly missing something in VS Code, but I don't have even the slightest clue as to what.
Can you check which interpreter is VSCode using because sometimes VSCode downloads the interpreter somewhere else. To change the environment of VSCode you can take a look at https://code.visualstudio.com/docs/python/environments
Just Set Your Browser:
import webbrowser
firefoxPath = "C:/Program Files/Mozilla Firefox/firefox.exe %s"
webbrowser.get(firefoxPath).open(firstUrl)
in VScode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.