錯誤寶典


錯誤信息1:SyntaxError:invalid syntax--無效語法

解決辦法:變量名不能使用關鍵字如下圖:

錯誤信息2:TypeError:'str' object is not callable--字符串對象不是可以輸出的

解決辦法:不建議使用Python內置方法為變量名、print這個函數的名字給覆蓋、使用print的時候找到的是自己定義的值

錯誤信息3:TypeError: Can't convert 'int' object to str implicitly--類型錯誤無法隱式將“int”對象轉換為str(環境是Python3.5版本)

解決辦法:用int轉下str字符串類型

錯誤信息4:TypeError: must be str, not int--類型錯誤必須是字符串不能是整型(Python3.6版本)

 解決辦法:用int轉下str字符串類型

錯誤信息5:TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'--類型錯誤int()參數必須是字符串、類似對象的字節或數字,而不是'nonet'

解決辦法:

錯誤信息6:TypeError: %d format: a number is required, not str--類型錯誤、格式需要數字而不是字符串

解決辦法:字符串前面加int

錯誤信息6:TypeError: not enough arguments for format string--typeerror:格式字符串的參數不足

解決辦法:增加缺少占位的參數。

錯誤信息7:TypeError: not all arguments converted during string formatting--typeerror:不是所有在字符串格式化期間轉換的參數

解決辦法:參數過多了要去掉。

錯誤信息8:'tuple' object doesn't support item deletion--“tuple”對象不支持項刪除

錯誤信息9:RuntimeError: dictionary changed size during iteration--運行時錯誤:字典在迭代期間更改了大小

錯誤信息10:RuntimeError: Set changed size during iteration--運行時錯誤:在迭代期間設置更改的大小。

錯誤信息11:IndentationError: expected an indented block--縮進錯誤:需要縮進的塊

錯誤信息12:TypeError: write() argument must be str, not int--typeerror:write()參數必須是str,而不是int

錯誤信息13:IndentationError: unexpected indent--縮進錯誤:意外縮進。

錯誤信息14:TypeError: list indices must be integers or slices, not str--列表的索引必須是整數或切片、而不是str

錯誤信息15:NameError: name 's' is not defined--名稱錯誤:名稱不是定義。

錯誤信息16:SyntaxError: keyword argument repeated--語法錯誤:關鍵字參數重復

錯誤信息17:TypeError: 'a1' is an invalid keyword argument for this function--類型錯誤:'a1'是此函數的無效關鍵字參數

錯誤信息18:TypeError: 'int' object is not callable--類型錯誤:int對象不可調用。

錯誤信息19:TypeError: 'int' object is not callable--類型錯誤、int對象不可調用

錯誤信息20:IndentationError: unexpected indent--縮進錯誤、意外縮進

錯誤信息21:UnboundLocalError: local variable 'name' referenced before assignment--取消綁定本地錯誤、賦值前引用的局部變量"name"

錯誤信息22:SyntaxError: no binding for nonlocal 'a' found--語法錯誤、未找到非本地a的綁定

解決辦法:nonlocal不能放在global下面

錯誤信息23:TypeError: <lambda>() missing 1 required positional argument: 'i'--類型錯誤、lambda缺少一個必須的位置參數

解決辦法:em里面增加值

錯誤信息24:TypeError: list indices must be integers or slices, not str--類型錯誤:列表索引必須是整數或切片,而不是str

錯誤信息25:ValueError: too many values to unpack (expected 2)--值錯誤:要解包的值太多(應為2)

錯誤信息26:TypeError: 'type' object is not subscriptable--typeerror:“type”對象不可訂閱

錯誤信息27:TypeError: run_time() missing 1 required positional argument: 'f'--typeerror:run_time()缺少1個必需的位置參數:“f”

錯誤信息28:TypeError: '<' not supported between instances of 'dict' and 'dict'--類型錯誤:“dict”和“dict”的實例之間不支持“<”

錯誤信息29:TypeError: 'generator' object is not subscriptable--typeerror:“generator”對象不可訂閱

錯誤信息30:TypeError: unsupported operand type(s) for +: 'function' and 'str'--typeerror:不支持+的操作數類型:“function”和“str”

錯誤信息31:RecursionError: maximum recursion depth exceeded while calling a Python object--遞歸錯誤:調用Python對象時,最大遞歸深度超過了

  [Previous line repeated 993 more times]--[上一行重復993次]

錯誤信息32:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape--syntaxerror:(unicode錯誤)“unicode escape”編解碼器無法解碼位置2-3中的字節:截斷的\uxxx escape

錯誤信息33:ModuleNotFoundError: No module named 'lib'--moduleNotFounderror:沒有名為“lib”的模塊、循環導入報錯

錯誤信息34:AttributeError: module 'core.src' has no attribute 'login_dic'--屬性錯誤:attributeerror:模塊'core.src'沒有'login dic'屬性

錯誤信息35:ValueError: not enough values to unpack (expected 2, got 1)--值錯誤:沒有足夠的值來解包(應為2,得到1)

錯誤信息36:

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.--您看到這個錯誤是因為您的Django設置文件中有DEBUG=True。將其更改為False,Django將顯示處理程序為此狀態代碼生成的標准頁。

解決:selenium.common.exceptions.WebDriverException: Message: 'chromedriver' execu

解決辦法:
安裝與瀏覽器版本匹配的webdriver
1、打開谷歌瀏覽器, 在地址欄輸入 chrome://version/ 查看版本信息:

2、選擇合適版本的驅動下載,
下載地址:http://chromedriver.storage.googleapis.com/index.html

3.解壓下載的驅動放到指定目錄,代碼調用時指定該目錄即可。
解壓后的目錄:

將chromedriver.exe 放入安裝的selenium庫下


運行的程序如下:

from selenium import webdriver
chrome_driver=r"D:\Python\Anaconda\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe"
driver=webdriver.Chrome(executable_path=chrome_driver)
1
2
3

運行成功!!!!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM