for foldername in os.listdir(mainpath):
x = 0
if foldername[-4:] != ".rar":
path = mainpath + "\\" + foldername
for i in os.listdir(path):
if i[-4:] == '.jpg' or i[-5:] == '.jpeg':
#Do something with with image found
x += 1
if x > 0:
#images found
Python 在 x += 1 处不断给我一个语法错误
语法没有问题,每次找到图像时我都会增加变量并在主循环移动到新文件夹时将其重置 x = 0