扫码关注官方订阅号
闭关修行中......
requests 提供转码方法
pythonIn [1]: html.encoding Out[1]: 'ISO-8859-1' In [2]: html %%html html In [2]: html.encoding = 'gb2312' In [3]: print html.text[:500] <!DOCTYPE html> <!--[30,131,1] published at 2015-08-06 23:33:28 from #130 by system--> <html> <head> <link rel="icon" sizes="any" mask href="http://www.sina.com.cn/favicon.svg"> <meta name="theme-color" content="red"> <link rel="icon" type="image/x-icon" href="http://www.sina.com.cn/favicon.ico"> <meta http-equiv="Content-type" content="text/html; charset=gb2312" /> <title>新浪首页</title> <meta name="keywords" content="新浪,新浪网,SINA,sina,sina.com.cn,新浪首页,门户,资讯" /> <meta name="descript In [4]:
python
In [1]: html.encoding Out[1]: 'ISO-8859-1' In [2]: html %%html html In [2]: html.encoding = 'gb2312' In [3]: print html.text[:500] <!DOCTYPE html> <!--[30,131,1] published at 2015-08-06 23:33:28 from #130 by system--> <html> <head> <link rel="icon" sizes="any" mask href="http://www.sina.com.cn/favicon.svg"> <meta name="theme-color" content="red"> <link rel="icon" type="image/x-icon" href="http://www.sina.com.cn/favicon.ico"> <meta http-equiv="Content-type" content="text/html; charset=gb2312" /> <title>新浪首页</title> <meta name="keywords" content="新浪,新浪网,SINA,sina,sina.com.cn,新浪首页,门户,资讯" /> <meta name="descript In [4]:
http://stackoverflow.com/questions/28184863/how-to-decode-and-encode-w...这里情况与你的情况相似,
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
requests 提供转码方法
http://stackoverflow.com/questions/28184863/how-to-decode-and-encode-w...这里情况与你的情况相似,