Python出现:TabError: inconsistent use of tabs and spaces in indentation

Python出现:TabError: inconsistent use of tabs and spaces in indentation

  • 今天跑爬虫的时候遇到一个小问题
    错误
    问题在这
  • 这个说是制表符出了问题,我查了查,说是用sublime可以看清楚自己有没有打空格和制表符,其实用不用sublime不重要,我突然意识到的改代码用的是Notepad++记事本,这一复制~就的确可能会出现这个问题,于是开个编译器格式化一下就好。
  • 没自己done掉~
    image.png
回答: 当你在Python代码中遇到"TabError: inconsistent use of tabs and spaces in indentation"错误,这意味着你在缩进中混用了制表符和空格。这个错误通常是由于编辑器的设置问题引起的。为了解决这个问题,你可以按照以下步骤进行操作: 1. 检查你的代码中的缩进是否一致。确保你只使用空格或者只使用制表符来进行缩进,不要混用它们。 2. 如果你使用的是Notepad++编辑器,你可以将制表符设置为四个空格。这样可以避免混用的问题。\[2\] 3. 如果你遇到"IndentationError: expected an indented block"错误,这意味着你需要在该行进行缩进。你可以使用空格或制表符(但不能混用)来缩进。如果上一行以冒号结尾,那么下一行需要进行缩进。\[3\] 希望这些解决方法能够帮助你解决Python中的缩进错误。如果问题仍然存在,请检查你的代码并确保缩进的一致性。你也可以参考提供的参考链接来获取更多关于解决这个错误的信息。\[1\] #### 引用[.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^v91^control,239^v3^insert_chatgpt"}} ] [.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^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

椰子奶糖

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

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

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

打赏作者

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

抵扣说明:

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

余额充值