return and print in python -
how can return output of function print () in python? have following function
def read_image(raw_image_path): raw_image_path = get_one_track() open (raw_image_path) raw_image_file: content = raw_image_file.readlines() content in itertools.islice(content,1,len(content)): image_id = content.split()[0] driver_id = content.split()[2] camera_spec = content.split()[1] + content.split()[2] image_spec = [image_id,driver_id,camera_spec] image_folder_file = read_img_folders_file()[0] cam_spec=read_img_folders_file()[1] nb = read_img_folders_file()[2] image_path='' in range(nb-1): if cam_spec[i]== image_spec[2]: image_path=image_folder_file[i]+'/' raw_image= image_path+str(image_id).zfill(10)+'.png' #print (raw_image) return (raw image)
the problem when use print (raw_image) become images need
/home/stereo_front_left/0000001756.png /home/stereo_front_left/0000001757.png /home/stereo_front_left/0000001758.png
but when try them outside function become first one. can do?
if want have raw_image outside loop, need store them in list or somewhere , write "return all_raw_images".
all_raw_images = [] content in itertools.islice(content,1,len(content)): image_id = content.split()[0] driver_id = content.split()[2] camera_spec = content.split()[1] + content.split()[2] image_spec = [image_id,driver_id,camera_spec] image_folder_file = read_img_folders_file()[0] cam_spec=read_img_folders_file()[1] nb = read_img_folders_file()[2] image_path='' in range(nb-1): if cam_spec[i]== image_spec[2]: image_path=image_folder_file[i]+'/' raw_image= image_path+str(image_id).zfill(10)+'.png' all_raw_images.append(raw_image) return (all_raw_images)
Comments
Post a Comment