文件移动和复制
2018-01-01 本文已影响0人
hxc92
import os
from PIL import Image
import shutil
direct = os.scandir('家')
for file in direct:
im = Image.open(file.path)
x, y = im.size
if x/y == 3/4 or x/y == 4/3:
shutil.copy(file.path, "三比四/")
# os.rename(file.path, "三比四/%s" % file.name) 一直报错
else:
shutil.copy(file.path, '其他/')
# os.rename(file.path, '其他/%s' % file.name) 一直报错