TopSup icon indicating copy to clipboard operation
TopSup copied to clipboard

mac 下 打开浏览器乱码

Open rxctp opened this issue 7 years ago • 6 comments

浏览器 打开是乱码的 但是控制台不是,求解

rxctp avatar Jan 11 '18 06:01 rxctp

import urllib.parse

webbrowser.open("http://www.baidu.com/s?wd=" + urllib.parse.quote(question))

zmovane avatar Jan 11 '18 07:01 zmovane

这个最终怎么解决呢?python2貌似没有urllib.parse.quote

yemengsky avatar Jan 11 '18 07:01 yemengsky

https://wp-lai.gitbooks.io/learn-python/content/0MOOC/taobao.html

yemengsky avatar Jan 11 '18 08:01 yemengsky

可以尝试用chrom打开, def open_webbrowser(question): chrome_path = 'open -a /Applications/Google\ Chrome.app %s' url = "https://www.baidu.com/s?ie=UTF-8&wd=%s" % question webbrowser.get(chrome_path).open(url)

h080294 avatar Jan 11 '18 08:01 h080294

上两个方法都尝试了 识别还是乱码

star-andy avatar Jan 11 '18 12:01 star-andy

这是webbrowser的问题,改为

url = "https://www.baidu.com/s?wd=%s" % text subprocess.call(["open",url])

可以解决,亲测有效。 PS(查询速度还是太慢了,根本反应不过来啊:-()

IrvingRyan avatar Jan 15 '18 03:01 IrvingRyan