我是Python的初学者。我正在尝试运行以下代码来替换.txt批注文件中的某些标签。
import os
for txt_in in os.listdir(r"uncorrected-YOLO_darknet"):
with open(txt_in) as infile:
for line in infile:
word=line.split(" ")[0]
if word="6":
word.replace('6', '5')
elif word="9":
word.replace('9', '6')
elif word="10":
word.replace('10', '7')
elif word="11":
word.replace('11', '8')
else:
continue
break
但我收到以下错误:
File "<tokenize>", line 7
if word="6":
^
IndentationError: unindent does not match any outer indentation level
我试图找到缩进错误,但对我来说似乎不错。请帮助。 tnx!
您使用了错误的If和elif条件语法 尝试下面的代码