当前位置:网站首页>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) # None
It 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
边栏推荐
- Talk about the things that must be paid attention to when interviewing programmers
- 【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)
- Huawei machine test question: longest continuous subsequence
- Codeforces Global Round 19 ABC
- Vulnstack3
- Use the difference between "Chmod a + X" and "Chmod 755" [closed] - difference between using "Chmod a + X" and "Chmod 755" [closed]
- Open source SPL optimized report application coping endlessly
- Single line function*
- Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
- Summary and practice of knowledge map construction technology
猜你喜欢
openresty ngx_lua执行阶段
Grub 2.12 will be released this year to continue to improve boot security
A tab Sina navigation bar
Video display and hiding of imitation tudou.com
Day_ 17 IO stream file class
Win: use shadow mode to view the Desktop Session of a remote user
A label colorful navigation bar
How to build a technical team that will bring down the company?
Action News
Subject 3 how to turn on the high beam diagram? Is the high beam of section 3 up or down
随机推荐
R language uses logistic regression and afrima, ARIMA time series models to predict world population
Li Kou Jianzhi offer -- binary tree chapter
Interpretation of mask RCNN paper
Interesting practice of robot programming 15- autoavoidobstacles
[Digital IC hand tearing code] Verilog edge detection circuit (rising edge, falling edge, double edge) | topic | principle | design | simulation
Bert fine tuning skills experiment
RichView TRVStyle MainRVStyle
Grub 2.12 will be released this year to continue to improve boot security
Video display and hiding of imitation tudou.com
The most powerful new household god card of Bank of communications. Apply to earn 2100 yuan. Hurry up if you haven't applied!
Learn game model 3D characters, come out to find a job?
JVM - when multiple threads initialize the same class, only one thread is allowed to initialize
How to make a cool ink screen electronic clock?
Kotlin - 协程 Coroutine
问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
Action News
Serious bugs with lifted/nullable conversions from int, allowing conversion from decimal
Visual explanation of Newton iteration method
Codeforces Global Round 19 ABC
Numpy library introductory tutorial: basic knowledge summary