python报错_python 常见报错
python 常見報(bào)錯(cuò)
IndentationError: 縮進(jìn)錯(cuò)誤
IndentationError: expected an indented block
應(yīng)為縮進(jìn)快
必須統(tǒng)一使用tab 不能空格和tab混用
AttributeError: 屬性錯(cuò)誤
AttributeError: 'int' object has no attribute 'replace'
“int”對(duì)象沒有屬性“replace”
AttributeError: module 'datetime' has no attribute 'now'
包引用錯(cuò)誤模塊“datetime”沒有“now”屬性
先檢查是否拼寫錯(cuò)誤,再檢查有沒有安裝此包
NameError:名稱錯(cuò)誤
NameError: name 'lst' is not defined
未定義名稱
檢查引號(hào)中的內(nèi)容單詞是否錯(cuò)誤
SyntaxError:語法錯(cuò)誤
SyntaxError: invalid syntax
無效語法
先檢查單詞是否寫錯(cuò) 標(biāo)點(diǎn)是否錯(cuò)誤
SyntaxError: no binding for nonlocal 'a' found
未找到非本地“a”的綁定
SyntaxError: can't assign to literal
無法分配給文本
SyntaxError: unexpected EOF while parsing
分析時(shí)出現(xiàn)意外的EOF
TypeError: 類型錯(cuò)誤
TypeError: 'type' object is not subscriptable
對(duì)象不可訂閱
TypeError:can only concatenate str (not "int") to str
自能將字符串和字符串拼接,不能拼接int類型
TypeError: 'builtin _function _or _method ' object is not iterable
對(duì)象不可重復(fù)
TypeError: 'str' object cannot be interpreted as an integer
對(duì)象不能解釋為整數(shù)
TypeError: 'str' object is not callable
不可以被系統(tǒng)調(diào)用
TypeError: 'str' object does not support item assignment
對(duì)象不支持項(xiàng)分配
TypeError: unsupported operand type(s) for -: 'builtin_function_or_method' and 'float'
不支持-:“builtin_function_or_method”和“float”的操作數(shù)類型
TypeError: argument of type 'int' is not iterable
類型“int”的參數(shù)不可迭代
TypeError: string indices must be integers
字符串索引必須是整數(shù)
TypeError: list expected at most 1 arguments, got 2
列表最多需要1個(gè)參數(shù),得到2個(gè)
TypeError: sequence item 2: expected str instance, int found
序列項(xiàng)2:應(yīng)為str實(shí)例,找到int
TypeError: can only concatenate str (not "list") to str
只能將str(不是“l(fā)ist”)連接到str
TypeError: unhashable type: 'list'
不可顯示的類型:list
TypeError: extend() takes no keyword arguments
不接受關(guān)鍵字參數(shù)
TypeError: 'int' object is not callable
int對(duì)象不能被調(diào)用
TypeError: Can't instantiate abstract class wechatpay with abstract methods pay
無法用抽象方法pay實(shí)例化抽象類微信支付
KeyError: 鍵錯(cuò)誤
KeyError: 'l'
鍵'l'錯(cuò)誤
IndexError: 索引錯(cuò)誤
IndexError: tuple index out of range
元組索引超出范圍
IndexError: string index out of range
字符串索引超出范圍
ValueError: 值錯(cuò)誤
ValueError: substring not found
找不到字符串
ValueError: list.remove(x): x not in list
不在列表內(nèi)
ValueError: attempt to assign sequence of size 1 to extended slice of size 2
嘗試將大小為1的序列分配給大小為2的擴(kuò)展切片
ValueError:invalid literal for int() with base 10: '3.8'
浮點(diǎn)型字符串無法強(qiáng)制轉(zhuǎn)換成int型
RecursionError: 遞歸錯(cuò)誤
RecursionError: maximum recursion depth exceeded while calling a Python object
調(diào)用python對(duì)象時(shí)超過了最大遞歸深度
json報(bào)錯(cuò)
json.decoder.JSONDecodeError: Extra data: line 1 column 13 (char 12)
額外數(shù)據(jù):第1行第13列(char 12)
未綁定的局部錯(cuò)誤
UnboundLocalError: local variable 'a' referenced before assignment
在賦值之前引用了局部變量“a”
網(wǎng)絡(luò)編程錯(cuò)誤
OSError: [Errno 48] Address already in use
地址已在使用中
關(guān)閉正在運(yùn)行的同地址的即可
argument of type 'int' is not iterableConnectionRefusedError: [Errno 61] Connection refused
類型“int”的參數(shù)不是ITerableConnectionReutedError:[errno 61]連接被拒絕
沒有啟動(dòng)服務(wù)器,啟動(dòng)服務(wù)器即可
遇到錯(cuò)誤不要慌張
1.看哪一行有報(bào)錯(cuò),一般都是最后一行;根據(jù)提示進(jìn)行修改,一般是引用錯(cuò)誤啊,語法錯(cuò)誤啊什么的
2.實(shí)在找不到就print,一行行打印結(jié)果排查
3.沒有自己代碼行的報(bào)錯(cuò),看源碼進(jìn)行分析,這個(gè)是最難的,一點(diǎn)點(diǎn)排查把
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的python报错_python 常见报错的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ps cs6 磨皮插件_PS后期磨皮插件
- 下一篇: nexus 安装_Jenkins Pip