1 import scipy.io as scio 2 dataFile = 'D:\\Users\\a\\Documents\\Tencent Files\\178026882\\FileRecv\\wiki.mat' 3 4 data = scio.loadmat(dataFile) 5 # print (type(data)) 6 a = (data['wiki'][0][0]) 7 # print(len(a)) 8 # print(a[2][0]) 9 # print('--------------------------------------------') 10 # print(a[3]) 11 lable =[] 12 lable_sex =[] 13 # print(a[2][0][0]) 14 for i in range(len(a[2][0])): 15 name = a[2][0][i] 16 sex = a[3][0][i] 17 name = list(name) 18 # print(name) 19 name_0 = str(name[0]) 20 # print(type(name_0)) 21 sex_float = str(sex) 22 # print(type(name[0])) 23 # print('full_path:',name[0],sex) 24 lable.append((name_0,sex_float)) 25 # print('gender:',sex) 26 # print(lable) 27 # aaa = [] 28 # print(lable) 29 for i in lable: 30 aaa = i 31 print(i[0]) 32 print(i[1]) 33 with open("lable2.txt", "a") as f: # 格式化字符串还能这么用! 34 f.write(i[0]) 35 f.write(' ') 36 f.write(i[1]) 37 f.write('\n')
附上自己从wiki.mat中提取出来的标签
https://pan.baidu.com/s/1dGT6ghV
再附上wiki的数据集地址