1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import os import glob
def list_image_files(folder_path): image_files = glob.glob(os.path.join(folder_path, '*.png')) + \ glob.glob(os.path.join(folder_path, '*.jpg')) + \
n=1 for file in image_files:
file_name = os.path.basename(file) print('"'+"Tieba"+str(n)+'":', '"Tieba/'+file_name+'",') n=n+1
folder_path = 'D:/data/Tieba' list_image_files(folder_path)
|