作者wahahahaaa (hah)
看板Python
标题[问题] 中文输出变乱码
时间Tue Aug 27 19:11:36 2019
请教各位版大
最近在练习用python开启网页.
import webbrowser
address = input("请输入地址: ")
webbrowser.open('
https://www.google.com.tw/maps/place/'+address)
输入中文地址时 开启的网页最後面都变成乱码
试过encode('utf-8') 但好像只用在输入 输出解决不了
请问该怎麽办呢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.138.50.134 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1566904299.A.076.html
1F:推 papple23g: 加上这行处理地址编码 08/27 21:46
2F:→ papple23g: import urllib.parse 08/27 21:46
3F:→ papple23g: address = urllib.parse.quote(address) 08/27 21:46
5F:→ coeric: 变成「看起来的乱码」,也不影响作业阿 08/28 10:45
6F:→ wahahahaaa: 感谢大大 太神了. 已解决!! 08/28 19:05