当前位置 : 主页 > 编程语言 > python >

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

来源:互联网 收集:自由互联 发布时间:2022-06-18
在用 Github 一个开源库 ruptures 做突变点检测时,调用它的 display 方法可视化检测结果时,觉得效果一般,如下所示: 找到 display 的源码分析,改造它的 matplotlib 绘图部分: 改进绘制折



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

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

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

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

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

改进绘制折线图的线条颜色,刻度的字体为 ​​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 后再执行代码就不会报错啦。


【文章转自香港云服务器 http://www.1234xp.com 复制请保留原URL】
网友评论