久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

python 使用requests 訪問 繁體字網(wǎng)站會出現(xiàn)亂碼,不知怎么解決?

瀏覽:130日期:2022-09-23 16:31:41

問題描述

In [12]: r = requests.get(’http://www.hkex.com.hk/chi/stat/smstat/dayquot/d170202c.htm’)In [13]: r.text[-100:]Out[13]: ’′á?§$2.60rn 717 xad^?ó?ò¨é ¥?′á?§$0.0128rnrn2. ?ü??xad×xadqrnrn-rnrn</font></pre></body></html>rn

問題解答

回答1:

根據(jù)該網(wǎng)頁的代碼:

<html><head><meta name=’MS.LOCALE’ content=’ZH-TW’><title>Hong Kong Exchanges and Clearing Limited</title><meta http-equiv=’Content-Type’ content=’text/html; charset=big5’>

需指定字符編碼為 big5:

r = requests.get(’http://www.hkex.com.hk/chi/stat/smstat/dayquot/d170202c.htm’)r.encoding = ’big5’

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 衢州市| 桂阳县| 阜新| 青河县| 凌云县| 柞水县| 东港市| 穆棱市| 贵溪市| 松原市| 称多县| 揭阳市| 乐平市| 新乐市| 赤壁市| 建昌县| 乳山市| 繁峙县| 巴塘县| 桦甸市| 尼勒克县| 金川县| 台湾省| 新河县| 大田县| 浏阳市| 平罗县| 高尔夫| 交口县| 沁水县| 鹤岗市| 余江县| 密山市| 龙胜| 台东市| 江口县| 漳平市| 宝山区| 民和| 宜昌市| 微山县|