Python 2.7 如何读取URL文件,然后使用python在浏览器中启动所有URL

Python 2.7 如何读取URL文件,然后使用python在浏览器中启动所有URL,python-2.7,Python 2.7,在Python2.x中,如何读取URL文件,然后在浏览器中启动所有URL 启动URL import webbrowser webbrowser.open('http://www.google.com') 如何让它从文本文件启动所有URL 在文本文件中显示URL,如下所示: 您还可以尝试webbrowser.open(url,2)来打开新选项卡中的链接 with open('Path/to/file', 'r') as content_file: content = content_

在Python2.x中,如何读取URL文件,然后在浏览器中启动所有URL

启动URL

import webbrowser
webbrowser.open('http://www.google.com')
如何让它从文本文件启动所有URL

在文本文件中显示URL,如下所示:

您还可以尝试
webbrowser.open(url,2)
来打开新选项卡中的链接

with open('Path/to/file', 'r') as content_file:
    content = content_file.read()
    urls = content.split()
    for url in urls:
         webbrowser.open(url)