掌握這些Python代碼報錯提示單詞輕松幫你解決bug

2021年2月19日14:40:31 發(fā)表評論 2,496 ℃

掌握這些Python代碼報錯提示單詞輕松幫你解決bug

1. syntaxerror: invalid syntax語法錯誤:無效語法

1) syntax [?s?nt?ks] 語法、句法

2) error [?er?r] 錯誤

3) invalid [?n?v?l?d] 無效

2. syntaxerror: unexpected EOF while parsing語法錯誤:多了無法解析的符號(檢查是否多了或少了括號)

1) expected [?k?spekt?d] 預(yù)料、預(yù)期

2) unexpected [??n?k?spekt?d] 想不到的

3) parsing [?pɑ?z??] 句法分析

3. syntaxerror: invalid character in identifier語法錯誤:有無效標識符(檢查中文符號)

1) character [?k?r?kt?r] 性格

2) identifier [a??dent?fa??] 標識符

4. indexerror: list index out of range索引錯誤:列表超出索引范圍(檢查列表是否為空)

1) list [l?st] 列表

2) index [??ndeks] 索引

3) error [?er?r] 錯誤

4) range [re?nd?] 范圍

5. typeerror: must be str, not int類型錯誤:數(shù)據(jù)不是正確的數(shù)據(jù)類型,比如字符串和數(shù)字直接拼接(檢查數(shù)據(jù)類型)

1) type [ta?p] 類型

6. indentationerror: expected an indented block縮進錯誤:檢查代碼的縮進是否正確

1) indentation [??nden?te??n] 行首縮進

2) expected [?k?spekt?d] 檢查

3) indented [?n?dent?d] 縮進的

4) block [bl?k] 塊

7. valueerror: substring not found值錯誤:輸入的數(shù)據(jù)類型跟要求不符合

1) substring 子串

2) found [fa?nd] 建立

8. nameerror: name 'a' is not defined未初始化對象,變量沒有被定義

1) defined [d??fa?nd] 定義

9. attributeerror: 'tuple' object has no attribute 'remove'屬性錯誤:該對象沒有這個屬性、方法(檢查數(shù)據(jù)類型)

1) attribute [??tr?bju?t] 屬性

2) tuple 元組、數(shù)組

3) object [??bd??kt] 對象

4) remove [r??mu?v] 移開、拿開、去掉

【騰訊云】云服務(wù)器、云數(shù)據(jù)庫、COS、CDN、短信等云產(chǎn)品特惠熱賣中

發(fā)表評論

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: