python urllib.request.urlopen 中文乱码问题

urllib.request.urlopen

getheader('Content-Disposition')

发现取出来的是乱码. 

最后查到问题出在浏览器的编码上.  解决方法:

s1.encode('ISO8859-1').decode('gbk')  // 使用chrome

 

1, IE浏览器,采用URLEncoder编码

2, Opera浏览器,采用filename*方式

3, Safari浏览器,采用ISO编码的中文输出

4, Chrome浏览器,采用Base64编码或ISO编码的中文输出

5, FireFox浏览器,采用Base64或filename*或ISO编码的中文输出

 

posted @ 2021-02-17 16:50  清源居士  阅读(687)  评论(0编辑  收藏  举报