我需要遍歷文件夾名稱,然後通過圖像,但我有這個錯誤。可能有人告訴我如何避免錯誤?如何避免將字符串添加到生成器表達式的錯誤?
path = '/.../'
dirs = next(os.walk(path))[1] # get my folder names inside my directory
for i in dirs:
for img in os.listdir(path+(x for x in dirs)): <------ TypeError: must be str, not generator
img_path = os.path.join(path,img)
print(img_path)
謝謝,這正是我想要的 –