TabError: inconsistent use of tabs and spaces in indentation问题解决 (ubuntu16.04+python3.6 )

报错:
# python test_yolo.py model_data/yolo.h5

  File "test_yolo.py", line 118
    print('image_file =',image_file)
                                   ^
TabError: inconsistent use of tabs and spaces in indentation

IndentationError: unindent does not match any outer indentation level

原因:

ubuntu(linux)下,缩进用空格(Space)键,如果用Tab键,系统报错。windows下不存在该问题。

print('image_file =',image_file) 改行缩进使用了Tab键。

解决办法:

用Tab的位置使用空格(Space)键替换。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
TabError: inconsistent use of tabs and spaces in indentation是Python中常见的错误之一。这个错误的原因是在代码缩进中混用了Tab和空格。Python要求在同一个代码块的缩进中只能使用一种方式,要么使用Tab缩进,要么使用空格缩进。混用这两种缩进方式会导致TabError错误的发生。 解决这个错误的方法是统一使用一种缩进方式。可以通过在编辑器中设置将Tab转换为空格,或者将空格转换为Tab。具体的设置方法可以参考引用中的链接,根据具体的编辑器进行相应的设置。 在修改缩进方式后,重新运行代码,这个错误应该就会消失了。 总结起来,TabError: inconsistent use of tabs and spaces in indentation这个错误是由于代码中混用了Tab和空格两种缩进方式造成的,解决方法是统一使用一种缩进方式。123 #### 引用[.reference_title] - *1* [Python报错 TabError: inconsistent use of tabs and spaces in indentation](https://blog.csdn.net/qq_39779233/article/details/107044126)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *2* *3* [Python避坑之TabError: inconsistent use of tabs and spaces in indentationIndentationError错误](https://blog.csdn.net/weixin_45900357/article/details/125020403)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CN.LG

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值