python中的tkinter的常見(jiàn)錯(cuò)誤有哪些

小樊
114
2024-08-21 06:46:26

  1. NameError: name ‘Tk’ is not defined - 未正確導(dǎo)入tkinter模塊

  2. TclError: unknown option “-xxx” - 在創(chuàng)建組件時(shí)使用了不存在的選項(xiàng)

  3. ValueError: Invalid literal for int() with base 10 - 嘗試將無(wú)法轉(zhuǎn)換為整數(shù)的值傳遞給組件

  4. AttributeError: ‘NoneType’ object has no attribute ‘config’ - 嘗試對(duì)未創(chuàng)建的組件進(jìn)行配置

  5. SyntaxError: invalid syntax - 拼寫(xiě)錯(cuò)誤或語(yǔ)法錯(cuò)誤

  6. TypeError: ‘str’ object is not callable - 嘗試將字符串作為函數(shù)調(diào)用

  7. UnboundLocalError: local variable ‘variable’ referenced before assignment - 嘗試在變量賦值之前引用變量

  8. KeyError: ‘key’ - 嘗試訪問(wèn)字典中不存在的鍵

  9. IndentationError: unexpected indent - 縮進(jìn)錯(cuò)誤

  10. IndexError: list index out of range - 嘗試訪問(wèn)超出列表范圍的索引

0