Python“TypeError: 'NoneType' object is not iterable"原因Python“TypeError: 'NoneType' object is not iterable"原因Python“TypeError: 'NoneType' object is not iterable"原因Python“TypeError: 'NoneType' object is not iterable"原因
  • 首页
  • 博客
  • 书签
  • 文件
  • 分析
  • 登录

Python“TypeError: 'NoneType' object is not iterable"原因

发表 admin at 2022年3月15日
类别
  • Python
标签

Python报 TypeError: 'NoneType' object is not iterable

原因:
None是不可迭代的。

list1 = ["a",'b']
list2 = list1.reverse()  # list1.reverse() 不应赋值给另一个变量,此时list2的值为None
for i in list2: # 因为list2的值为None,无法迭代,所以报错
    print(i)

发表回复 取消回复

要发表评论,您必须先登录。

类别

  • Cat
  • Python
  • Django
  • Database
  • Html/CSS
  • JavaScript
  • Vue
  • RegExp
  • Maths/AI
  • PHP/Wordpress
  • Practice
  • Linux
  • Windows
  • Android
  • NAS
  • Software
  • Hardware
  • Network
  • SEO
  • English
  • Games
  • Recipes
  • General
  • Memorandum
  • Essays
  • 未分类

归档

©2015-2023 艾丽卡 Blog support@alaica.com
      ajax-loader