Python中的常见错误

Python中的常见错误

#这边文章是一边出错一边来记录的,所以可能不是那么的有体系

1、缩进错误

下面所提示的错误是
IndentationError:expected an intended block
意思就是该缩进的地方没有缩进,要好好检查一下

2、返回值为None

#在给列表添加元素时,第一种方法返回值很正常
list1=[1,2,3,4]        #方法一
list1.insert(1,100)
print(list1)

[1, 100, 2, 3, 4]

list1=[1,2,3,4]        #方法二
list2=list1.insert(1,100)
print(list2)

None        #第二种情况的返回值为None

猜你喜欢

转载自blog.csdn.net/weixin_43540603/article/details/85380541