解决TabError: inconsistent use of tabs and spaces in indentation

简介: inconsistent use of tabs and spaces in indentation

在用 Github 一个开源库 ruptures 做突变点检测时,调用它的 display 方法可视化检测结果时,觉得效果一般,如下所示:



找到 display 的源码分析,改造它的 matplotlib 绘图部分:




改进绘制折线图的线条颜色,刻度的字体为 Times New Roman 和调整大小。


保存后,执行 Python 脚本时遇到:TabError: inconsistent use of tabs and spaces in indentation,意思是不要混合使用 4 个空格和 tab 键


解决的方法:


  • Sublime Text里设置:Preferences -> Settings,设置显示制表符:“draw_white_space”: “all”
  • 以及设置 tab 键自动转化为四个空格,如下所示:


"tab_size": 4,
"translate_tabs_to_spaces": true,
"expand_tabs_on_save": true


然后重启 jupyter notebook 后再执行代码就不会报错啦。


博客园 | 解决TabError: inconsistent use of tabs and spaces in indentation


目录
相关文章
|
11月前
|
JavaScript
解决 NavigationDuplicated: Avoided redundant navigation to current location: “/“
解决 NavigationDuplicated: Avoided redundant navigation to current location: “/“
156 0
解决 NavigationDuplicated: Avoided redundant navigation to current location: “/“
|
IDE 开发工具 Python
TabError: inconsistent use of tabs and spaces in indentation
这个报错的意思是说IDE分不清tab和空格,说明你的代码中混用了tab和空格。
250 0
TabError: inconsistent use of tabs and spaces in indentation
|
JavaScript
vue 里 使用 eslint 报错 error:Mixed spaces and tabs (no-mixed-spaces-and-tabs)
vue 里 使用 eslint 报错 error:Mixed spaces and tabs (no-mixed-spaces-and-tabs)
338 0
vue 里 使用 eslint 报错 error:Mixed spaces and tabs (no-mixed-spaces-and-tabs)
inconsistent use of tabs and spaces in indentation
inconsistent use of tabs and spaces in indentation
88 0
inconsistent use of tabs and spaces in indentation
|
Python
Python 缩进问题-inconsistent use of tabs and spaces in indentation.原因及解决方法
Python 缩进问题-inconsistent use of tabs and spaces in indentation.原因及解决方法
5566 0
Python 缩进问题-inconsistent use of tabs and spaces in indentation.原因及解决方法
get assigned pageset and my pages
get assigned pageset and my pages
80 0
get assigned pageset and my pages