Python報UnicodeDecodeError
在進行開啟檔案過程中,提示UnicodeDecodeError錯誤,這可能是Python嘗試用gbk編碼開啟一個非gbk編碼的檔案(Windows下Python預設使用gbk讀取檔案)導致。
解決:
在開啟時指定編碼。
報錯語句:
soup = BeautifulSoup(open(“c:\\user\desktop\sina.html”))
修改後:
soup = BeautifulSoup(open(“c:\\user\desktop\sina.html”,encoding="utf-8"))
注:上述中"\U"是轉義字元,如果直接是c:\user...則會提示SyntaxError,這時我們就需要多加一個“\”
相關文章
- Python報錯:UnicodeDecodeError: 'gbk' codec can't decode byte ...PythonUnicodeError
- Django2.2 報錯:UnicodeDecodeError 解決方法DjangoUnicodeError
- 對於python中出現UnicodeDecodeError問題的解決方案PythonUnicodeError
- 如何理解 python UnicodeEncodeError 和 UnicodeDecodeError :python 的 string 和 unicodePythonUnicodeError
- pip install 報錯UnicodeDecodeError: 'ascii' codec can't decode byteUnicodeErrorASCII
- 【廖雪峰python入門筆記】Unicode編碼_UnicodeDecodeError處理Python筆記UnicodeError
- Python3.7使用pip install xxxx報錯:UnicodeDecodeError: 'gbk' codec can't decode bytePythonUnicodeError
- python在用pandas對csv檔案處理的時候報UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb6。。。的錯誤PythonUnicodeError
- Python讀取csv檔案出現解碼錯誤UnicodeDecodeError: ‘utf-8‘ codec can‘t decodPythonUnicodeError
- pip install ... ERROR: UnicodeDecodeError: ‘gbk‘ codec can‘t decode/ python setup.py egg_info CheckErrorUnicodePython
- python報錯Python
- python的報錯Python
- 【python 監控報警】python自動發微信監控報警Python
- 38. 報數(python)Python
- python分析文字報告Python
- Python報錯總結Python
- python-pycharm報錯PythonPyCharm
- 【Python】升級python後pip報錯Python
- Python讀取檔案時出現UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position xx: 解決方案PythonUnicodeError
- python3 print報錯Python
- Python釘釘報警及Zabbix整合釘釘報警Python
- python值得報班學習嗎Python
- Python指令碼典型報錯(1)Python指令碼
- Python指令碼典型報錯(2)Python指令碼
- python實現報表用什麼?Python
- Python 入門級報錯處理Python
- Linux:Python報錯:No module named MySQLdbLinuxPythonMySql
- python報名系統抗壓測試Python
- Vue安裝依賴報錯:checking for Python executable "python" in the PATHVuePython
- Python分析3月政府工作報告Python
- Python 實現自動化 Excel 報表PythonExcel
- python virtualenv報錯-bash: virtualenv: command not foundPython
- 1.python報錯:TypeError: 'int' object is not subscriptablePythonErrorObject
- python報錯wxPyDeprecationWarning:UsingdeprecatedclassPySimpleApp.PythonAPP
- python3升級後的報錯Python
- 系統巡檢Python生成word報告🧫Python
- pipenv install error UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in positionErrorUnicode
- Python 執行報錯 PermissionError: [Errno 13] Permission denied: '***.***'PythonError