txt中数据如下所示。其中jpg和1之间为tab空格。下面代码实现读取txt中的数据,并输出。
import os
f = open("all_mixed.txt","r")
while True:
lines = f.readline()
if not lines:
break
pass
p_tmp = [i for i in lines.split()]
filename = p_tmp[0]
label = int(p_tmp[1])
print(filename," ", label)