当前位置:网站首页>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
边栏推荐
- 如何搭建一支搞垮公司的技術團隊?
- From task Run get return value - getting return value from task Run
- Educational Codeforces Round 122 (Rated for Div. 2) ABC
- Using druid to connect to MySQL database reports the wrong type
- Uniapp navigateto jump failure
- Vulnstack3
- Luo Gu Pardon prisoners of war
- He was laid off.. 39 year old Ali P9, saved 150million
- Win: add general users to the local admins group
- 使用druid连接MySQL数据库报类型错误
猜你喜欢

Naacl 2021 | contrastive learning sweeping text clustering task

Tucson will lose more than $400million in the next year

如何做一个炫酷的墨水屏电子钟?

Bumblebee: build, deliver, and run ebpf programs smoothly like silk

Practical case of SQL optimization: speed up your database

Openresty ngx Lua Execution stage

Restful fast request 2022.2.1 release, support curl import

runc hang 导致 Kubernetes 节点 NotReady

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

Security level
随机推荐
STL container
Some query constructors in laravel (2)
使用druid連接MySQL數據庫報類型錯誤
CAM Pytorch
A label colorful navigation bar
[illumination du destin - 38]: Ghost Valley - chapitre 5 Flying clamp - one of the Warnings: There is a kind of killing called "hold Kill"
Practice of tdengine in TCL air conditioning energy management platform
Learn tla+ (XII) -- functions through examples
Comment mettre en place une équipe technique pour détruire l'entreprise?
Codeforces Round #770 (Div. 2) ABC
How to find hot projects in 2022? Dena community project progress follow-up, there is always a dish for you (1)
Start the remedial work. Print the contents of the array using the pointer
I use these six code comparison tools
RichView TRVStyle MainRVStyle
Data guard -- theoretical explanation (III)
runc hang 导致 Kubernetes 节点 NotReady
Tucson will lose more than $400million in the next year
Win:将一般用户添加到 Local Admins 组中
85.4% mIOU! NVIDIA: using multi-scale attention for semantic segmentation, the code is open source!
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool