except IOError as e: using python 3 but shows invalid syntax -
i edit code, seems not error of mising 'try':
def load_letter(folder, min_num_images): image_files = os.listdir(folder) dataset = np.ndarray(shape=(len(image_files), image_size, image_size), dtype=np.float32) print(folder) num_images = 0 image in image_files: image_file = os.path.join(folder, image) try: image_data = (ndimage.imread(image_file).astype(float) - pixel_depth / 2) / pixel_depth if image_data.shape != (image_size, image_size): raise exception('unexpected image shape: %s' % str(image_data.shape)) dataset[num_images, :, :] = image_data num_images = num_images + 1 except ioerror e: print('could not read:', image_file, ':', e, '- it\'s ok, skipping.') dataset = dataset[0:num_images, :, :] and i'm using python 3 not python 2 shows error:
except exception e: ^ syntaxerror: invalid syntax
i don't understand why since i'm using py3
Comments
Post a Comment