当前位置:网站首页>Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
2022-07-05 02:22:00 【Gongzicong】
python Medium append() Method is used for Add a new object at the end of the list .
The method No return value ( That is, the return value is null ), however Will modify the original list .
a = [1, 2, 3]
b = a.append(4)
print(a) # [1, 2, 3, 4]
print(b) # NoneIt can be seen from the result execution ,append() no return value (b The value of is empty ), So if b Add a new object on , namely :
b.append(5) An error will be reported after execution AttributeError: 'NoneType' object has no attribute 'append'
because b It's an empty type , Not a list type , So there was no append() Method , Here should be b.append(5) It is amended as follows a.append(5)
Summary :
append() Method is used to add a new object at the end of the list , no return value , But it changes the original list .
therefore , In the use of append() When the method is used , You cannot assign its execution result to other variables before viewing or other operations .
Reference material :
https://www.runoob.com/python/att-list-append.html
https://blog.csdn.net/weixin_44249185/article/details/102580621
边栏推荐
- Using druid to connect to MySQL database reports the wrong type
- Summary of regularization methods
- Asynchronous and promise
- Redis distributed lock, lock code logic
- 使用druid連接MySQL數據庫報類型錯誤
- 【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)
- [uc/os-iii] chapter 1.2.3.4 understanding RTOS
- Kotlin - coroutine
- Restful Fast Request 2022.2.1发布,支持cURL导入
- Serious bugs with lifted/nullable conversions from int, allowing conversion from decimal
猜你喜欢

Application and Optimization Practice of redis in vivo push platform

【附源码】基于知识图谱的智能推荐系统-Sylvie小兔

【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)

JVM - when multiple threads initialize the same class, only one thread is allowed to initialize

如何搭建一支搞垮公司的技术团队?

Restful fast request 2022.2.1 release, support curl import

Chinese natural language processing, medical, legal and other public data sets, sorting and sharing

Icu4c 70 source code download and compilation (win10, vs2022)

Restful Fast Request 2022.2.1发布,支持cURL导入

Application and Optimization Practice of redis in vivo push platform
随机推荐
Collection of gmat750 wrong questions
[Digital IC hand tearing code] Verilog edge detection circuit (rising edge, falling edge, double edge) | topic | principle | design | simulation
Comment mettre en place une équipe technique pour détruire l'entreprise?
Luo Gu Pardon prisoners of war
Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
ICSI 311 Parser
Summary of regularization methods
【LeetCode】98. Verify the binary search tree (2 brushes of wrong questions)
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
February database ranking: how long can Oracle remain the first?
The most powerful new household god card of Bank of communications. Apply to earn 2100 yuan. Hurry up if you haven't applied!
Marubeni Baidu applet detailed configuration tutorial, approved.
[机缘参悟-38]:鬼谷子-第五飞箝篇 - 警示之一:有一种杀称为“捧杀”
openresty ngx_lua变量操作
Application and development trend of image recognition technology
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
[technology development-26]: data security of new information and communication networks
RichView TRVUnits 图像显示单位
. Net starts again happy 20th birthday
Talk about the things that must be paid attention to when interviewing programmers