問題解決:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
鄭重宣告:本人目前僅在CSDN這一個平臺釋出文章,其他小夥伴如果想轉載 或者引用請註明引用來源,未經許可不得直接搬運,請尊重創作人的勞動成果,謝謝!
一、錯誤出現
今天在寫程式碼時出現瞭如下的錯誤:
用我非常地道的英文翻譯一下(嘿嘿,自吹一下)應該是空型別物件沒有append屬性,然後對照提示的錯誤程式碼的位置發現是temp = temp.append(new_accusation)
這句出現了問題,根據提示的錯誤我馬上想到難道temp是空型別嗎,於是我趕緊開始測試。
二、錯誤原因
我用type()函式檢視temp的型別print(type(temp.append(new_accusation)))
果然發現了問題,輸出如下:
還真的是空型別,既然知道了錯誤原因,那麼解決辦法也就顯而易見啦。
三、問題解決
這裡我又查了些資料,append()函式是會修改自身的,並且返回None,所以根本不能用變數去接收它。只要將前面的變數刪除即可,程式碼這樣改temp.append(new_accusation)
,然後就完美滴解決啦
本篇完,如有錯誤歡迎指出~
相關文章
- Traceback (most recent call last): File "AttributeError: 'NoneType' object has no attribute 'group'ASTErrorNoneObject
- AttributeError: 'Settings' object has no attribute 'HBase'ErrorObject
- 【坑】Tkinter ‘NoneType‘ object has no attribute ‘destroy‘NoneObject
- [轉]成功解決AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘?Error
- Rasa init報錯:AttributeError: type object 'Callable' has no attribute '_abc_registry'ErrorObject
- AttributeError: module ‘requests‘ has no attribute ‘_version_‘Error
- 解決pycharm問題:module 'pip' has no attribute 'main'PyCharmAI
- 【Error】AttributeError: module ‘scipy.misc‘ has no attribute ‘logsumexp‘ 的解決辦法Error
- Process object has no attribute '_popen'Object
- ‘dict‘ object has no attribute ‘iteritems‘Object
- 1_使用face_recognition模組:錯誤AttributeError:'PngStream' object has no attribute 'chunk fcWp'(20190223)ErrorObject
- ‘FirewallD‘ object has no attribute ‘path‘ 、‘fw‘、is not registeredObject
- AttributeError: module...ops‘ has no attribute ‘_TensorLike‘, ValueError: `updates` argument..eagerError
- AttributeError: module‘ tensorflow_core._api.v2. train‘ has no attribute‘ AdamOptimizer‘ErrorAPIAI
- AttributeError: module ‘tensorflow._api.v1.nn.rnn_cell‘ has no attribute ‘InputProjectionWrapper‘ErrorAPIRNNProjectAPP
- 問題解決:TypeError: unsupported format string passed to NoneType.__format__ErrorORMNone
- 解決The jar file has no source attachment問題JAR
- python去掉excel空格和換行,報錯'int' object has no attribute 'strip'PythonExcelObject
- python-unittest 框架利用 PageObject 設計模式在 BasePage 類中呼叫不到 send_keys 方法,執行報錯'NoneType' object has no attribute 'send_keys'Python框架Object設計模式None
- has been blocked by CORS policy跨域問題解決BloCCORS跨域
- multiprocessing pool AttributeError: Can't get attribute 'func'Error
- PHP Warning: exec() has been disabled for security 問題解決辦法PHP
- 複雜網路中louvain演算法實現時報錯AttributeError: module ‘community‘ has no attribute ‘best_partition‘AI演算法ErrorUnity
- 解決問題:啟動不了VM,提示 Your VM has become “inaccessible…
- npm ERR! code CERT_HAS_EXPIRED:解決證書過期問題NPM
- module ‘tensorflow‘ has no attribute ‘get_default_graph‘
- module ‘h5py‘ has no attribute ‘File‘H5
- Android學習開發(問題解決)——android Unable to inflate view tag without class attributeAndroidView
- Input報錯“Form elements must have labels: Element has no title attribute Element has no placeholde”ORM
- 介面返回[object,Object]解決方法Object
- Android gradle問題解決: This app has been built with an incorrect configuration. Please configure your b...AndroidGradleAPPUI
- 問題MySQL server has gone awayMySqlServerGo
- react-解決 fetch 跨域問題:Access to fetch at XXX from origin YYY has been blocked by CORS policyReact跨域BloCCORS
- Uncaught TypeError: external_echarts_.helper.createTextStyle is not a functionat Object.seriesModel.layoutInstance.ondraw問題的解決ErrorEchartsFunctionObject
- [提問交流]關於Jquery Append鉤子的問題,大神求助!jQueryAPP
- 解決MySQL server has gone away錯誤的解決方案MySqlServerGo
- 提問題比解決問題更重要
- 解決跨域問題跨域