如何在python中打开一个url
import urllib fun open(): return urllib.urlopen('http://example.com') 但是,当example.com打开它不呈现CSS或JS。 如何在networking浏览器中打开网页?
 @error(404) def error404(error): return webbrowser.open('http://example.com') 
 我正在使用瓶子。 给我的错误: TypeError("'bool' object is not iterable",) 
与网页浏览器模块
 import webbrowser webbrowser.open('http://example.com') # Go to example.com 
 import webbrowser webbrowser.open(url, new=0, autoraise=True) 
使用默认浏览器显示url。 如果新值为0,则尽可能在相同的浏览器窗口中打开该URL。 如果新值为1,则尽可能打开新的浏览器窗口。 如果新值为2,则尽可能打开新的浏览器页面(“选项卡”)。 如果自动调整为True,则窗口被抬起
 webbrowser.open_new(url) 
在默认浏览器的新窗口中打开url
 webbrowser.open_new_tab(url) 
在默认浏览器的新页面(“标签”)中打开url
你也必须读取数据。
检查: http : //www.doughellmann.com/PyMOTW/urllib2/了解它。
 response = urllib2.urlopen(..) headers = response.info() data = response.read() 
当然,你想要的是在浏览器中渲染它,并且aaronasterling的答案是你想要的。
你也可以尝试:
 import os os.system("start \"\" http://example.com") 
这个,除了@aaronasterling的答案,它的优点是,它打开默认的Web浏览器。 一定不要忘记“http://”。
导入网页浏览器
webbrowser.open(“把你的url在这些引号”)
我想这是使用这个函数打开一个URL的简单方法
 webbrowser.open_new_tab(url)