原创 GBK,Unicode,UTF-8編碼的相互轉換

說明: 1.在python2默認編碼是ASCII, python3裏默認是unicode。 2.unicode 分爲 utf-32(4個字節),utf-16(2個字節),utf-8(1-4個字節), utf-16是現在最常用的u

原创 解決TypeError: 'NoneType' object is not callable

今天跑代碼發現報錯: TypeError: ‘NoneType’ object is not callable 翻譯:“NoneType” 對象不可調用 分析解決: callable(可調用)對象是指一個後面可以加 ‘( ) ’的

原创 解決RecursionError: maximum recursion depth exceeded while calling a Python object

運行程序時遇到報錯: RecursionError: maximum recursion depth exceeded while calling a Python object 原因:Python默認遞歸調用深度爲1000(即最

原创 解決ValueError: complex() arg is a malformed string

ValueError: complex() arg is a malformed string 原因: 使用complex()方法將字符串轉化爲複數的時候,字符串中有空格符。 # 錯誤代碼: print(complex('1 +

原创 Python中元組,集合2種數據類型在某些情況下替換列表的優勢

Python3中給我們提供了6種標準數據類型: Number(數字)、String(字符串)、List(列表)、Tuple(元組)、Set(集合)、Dictionary(字典) 其中 : 數字、字符串、元組是不可變數據(定義後不可

原创 pycharm安裝python庫報錯ERROR: Command errored out with exit status 1:解決辦法

pycharm安裝python庫報錯ERROR: Command errored out with exit status 1:解決辦法 解決辦法: 1、下載該庫文件對應版本的.whl文件 下載地址:https://www.lfd

原创 解決Port Binding Error:IDLE can't bind to a TCP/IP port, which is necessary to communicate

Python 報錯: Port Binding Error: IDLE can’t bind to a TCP/IP port, which is necessary to communicate with its Python

原创 解決Python2不支持中文字符集SyntaxError: Non-ASCII character '\xe4' in file

在python2中,默認編碼是不支持中文字符集的 如果你要進行如下操作: a = '你好,世界' print(a) 運行則會報錯: SyntaxError: Non-ASCII character ‘\xe4’ in file

原创 程序報錯:AttributeError: module 'tensorflow' has no attribute 'xxx' 解決辦法

執行程序遇到報錯:AttributeError: module ‘tensorflow’ has no attribute ‘xxx’ 解決辦法 報錯例如: AttributeError: module ‘tensorflow’