当把代码从别处复制进来PyCharm,然后运行报错:TabError: inconsistent use of tabs and spaces in indentation
这个报错的意思是说IDE分不清tab和空格,说明你的代码中混用了tab和空格。
解决的方法有:
方法一. 找出所有的空格和tab
首先 File -> Settings -> Editor -> General -> Appearance -> Show whitespaces,如图所示:
File -> Default Settings -> Editor -> Code Style -> Python -> 在Tabs and Indents选项卡中,勾选“Use tab character”
之后再代码中就会显示出Tab为一个箭头,而空格的话就会显示为比较小的点
方法二:格式化代码!
具体操作是:Code -->Reformat Code
再次尝试运行即可!
参考文章:https://www.cnblogs.com/sgh1023/p/10013071.html