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"原因
  • 首页
  • 博客
  • 文件
  • 书签
  • 分析
  • 登录
Search
Generic filters

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

Published by admin at 2022年3月15日
Categories
  • Python
Tags

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)

发表回复 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Categories

  • 猫
  • Python
  • MySQL
  • Django
  • Html/CSS
  • JavaScript
  • Vue
  • RegExp
  • php
  • Practice
  • Virtualization
  • Linux
  • Windows
  • Android
  • NAS
  • Software
  • Hardware
  • Network
  • Router
  • Office
  • WordPress
  • SEO
  • English
  • Games
  • Recipes
  • living
  • Memorandum
  • Essays
  • 未分类

归档

©2015-2022 Alaica Blog support@alaica.com