import os
def read_txt(path):
all_box = []
with open(path, 'r') as f:
while True:
line = f.readline()
if line:
line = line.split("('")[-1]
line = line.split(")")[0]
line = line.replace("'", "")
lists = line.split(", ")
for i in range(4):
lists[i + 1] = int(lists[i + 1])
all_box.append(lists)
else:
break
return all_box
path = r"F:\pytorch\Annotations_pbox\000001.txt"
all_box = read_txt(path)
print(all_box)
aaa和sss分别是两个类名,后面4个数分别是左上角坐标(x1,y1),右下角坐标(x2,y2)