Search code examples
pythonpython-webbrowser

webbrowser.open() creates a new Document file Instead opening browser


I am trying to open a link in web browser through python command webbrowser.open() but every time i execute this, plus cursor(for selection) appears and whatever area i select got saved in file named "webbrowser".

Content of my foo.py file--

import webbrowser
webbrowser.open("http://www.google.com")

After selecting i got this error-

/foo.py: line 2: syntax error near unexpected token `"http://www.google.com"'

./foo.py: line 2:webbrowser.open("http://www.google.com"`);'

Here is the screenshot: screenshot.


Solution

  • I was missing this line " #!/usr/bin/python" at the top of my code.