寒假整理1:初学Python常见报错含义

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/BeerBread134/article/details/86917652

 

很久没用Python了,基础语法都要忘光了。虽然上学期用过Django写了一些网页,但是毕竟就是调来调去,和数据结构基础操作算法什么的完全不一样。之前准备简历时说自己会Python,所以寒假最后几天整理一下前年初学Python时的笔记,回忆一下。

 

TabError: inconsistent use of tabs and spaces in indentation

混用了tab和空格(space);

删掉自动缩进改为4个空格即可。

 

TypeError: bad operand type for abs(): 'str'

Abs()里数据类型错误,不应该用str;

 

TypeError: power() missing 1 required positional argument: 'n'

调用函数power()缺少了一个位置参数n;

 

TypeError: object doesn't support item assignment

对象不支持此操作;

 

IndentationError: unexpected indent

IndentationError: unindent does not match any outer indentation level

使用的缩进方式不一致,有的是 tab 键缩进,有的是空格缩进,改为一致即可;

猜你喜欢

转载自blog.csdn.net/BeerBread134/article/details/86917652