python 代码问题

def uncompress_features_labels(file):
global img_size
features = []
labels = []
current_label = ""

with ZipFile(file) as zf:
#Progress Bar
filenames_pbar = tqdm(zf.namelist(), unit='files')
#Features and labels
for i, filename in enumerate(filenames_pbar):
if not filename.endswith('/') and filename.endswith('.jpg'):
with zf.open(filename) as image_file:
image = Image.open(image_file).resize(img_shape,resample = PIL.Image.LANCZOS)
image_arr = normalize_pix(np.array(image, dtype=np.float32))
if filename[6:9] != current_label:
current_label = filename[6:9] if "/" in filename[6:10] else filename[6:11]

features.append(image_arr)
labels.append(current_label)

return np.array(features),np.array(labels)

#上面的代码里面这个怎么理解: current_label = filename[6:9] if "/" in filename[6:10] else filename[6:11]

第1个回答  2018-01-18
将filename 部分字符复制给lable
相似回答