[問題] Unicode Decode Error

看板Python作者 (suhang)時間11年前 (2014/10/29 13:29), 11年前編輯推噓1(105)
留言6則, 1人參與, 最新討論串1/1
我寫了一個crawler爬網頁 http://pastie.org/9682499#16,18 按照view page source <meta content="text/html; charset=Big5"> 我用Big5 解碼回傳的 byte string Python卻回應某些byte無法解碼 UnicodeDecodeError: 'big5' codec can't decode byte 0x82 in position 983: illegal multibyte sequence 1 瀏覽器也是設定Big5解碼 那為什麼瀏覽器可以正確的顯現所有內容? 2 我試著用utf8瞎猜去解碼,一樣有error 請問我該如何處理這個錯誤而能顯示我所抓下來的網頁? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 76.169.54.91 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1414560558.A.9C4.html

10/29 13:41, , 1F
please provide more info, code, and error messages
10/29 13:41, 1F
已補上 ※ 編輯: suhang (76.169.54.91), 10/29/2014 14:08:00

10/29 14:56, , 2F
0x82處於Big5編碼的使用者造字區裡 看來Python的
10/29 14:56, 2F

10/29 14:57, , 3F
Big5 codec不支援這些東西 瀏覽器可正常顯示是因為
10/29 14:57, 3F

10/29 14:57, , 4F
它們也擴充支援那些字元了(Unicode補完計畫?)
10/29 14:57, 4F

10/29 15:17, , 5F
嗯 或許可以呼叫外部程式(能從Big5轉成utf8)
10/29 15:17, 5F

10/29 16:00, , 6F
文章代碼(AID): #1KK7ikd4 (Python)
文章代碼(AID): #1KK7ikd4 (Python)