如何解决在 python 中遇到缩进错误的问题
def linear_probe(self,value,start_index):
hashed_key = start_index % len(self.table)
while self.table[hashed_key] is not None:
hashed_key = (hashed_key + 1) % len(self.table)
return hashed_key,value`enter code here`
嗨,这是我在实验室中使用的用于 linear_probe 函数的代码,但是由于某种原因,我一直得到 unindent 与任何外部缩进级别都不匹配。但是从我如何看到我的 Tab 键看起来不错并且没有空格
解决方法
您很可能混合使用制表符和空格。
请确保您的编辑器始终使用空格。
如果可能,让您的编辑器突出显示标签。
,发布的代码对整个函数有 2 个空格的缩进。从每行前面删除 2 个空格,然后重试:
## <-- accidental indent?
def linear_probe(self,value,start_index):
hashed_key = start_index % len(self.table)
while self.table[hashed_key] is not None:
hashed_key = (hashed_key + 1) % len(self.table)
return hashed_key,value`enter code here`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。