Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一个变量,比如说最喜欢的歌手,我想打开网络浏览器并搜索那个歌手。我打算用下面的代码来打开谷歌,但是我怎样才能让用户输入成为实际的搜索本身呢?
webbrowser.open('www.google.com')
要预填充搜索框,请使用:
import webbrowser from urllib import urlencode webbrowser.open('http://www.google.com/?' + urlencode({'q': 'the quick brown fox'}))