Reputation: 93
I got the foundation and ideas for this online. It works great when I run it in Windows 10 but not Ubuntu 16.04. On Ubuntu it mistakes the URL for a file and gives me a file not found error. Is this a user coding error, a Ubuntu problem, or a Python problem?
To be a bit more specific it is a gvfs-open error.
import webbrowser
new = 2
choice = raw_input('Type site name:\n> ')
site = choice
url1 = 'www..com'
url = url1[:4] + site + url1[4:]
webbrowser.open(url,new=new)
Here are the results.
$ gvfs-open: www.google.com: error opening location: error when getting information for file '/home/username/Documents/www.google.com: no such file or directory
Upvotes: 0
Views: 1716
Reputation: 93
I took Klaus D. advice and added http://
. Now it works on both OSs.
Thank you!
import webbrowser
new = 2
choice = raw_input('Type site name:\n> ')
site = choice
url1 = 'www..com'
url = 'http://' + url1[:4] + site + url1[4:]
webbrowser.open(url,new=new)
Upvotes: 1