各位友友們可以幫俺看看嗎?這是啥問題
以下我寫的代碼
#導入os模塊
import os
#導入image包
import shutil
from PIL import Image
path = "D:\python\gaizi"
save = "D:/python/abc_666"
file_list = os.listdir(path)
for file in file_list:
imgPath = os.path.join(path, file)
img = Image.open(imgPath)
imgSize = img.size
print(imgSize, imgPath)
minSize = min(imgSize)
if minSize >= 320:
images_min = os.path.join(save, file) + ".jpg"
shutil.copy(imgPath, images_min)
img.close()
print(minSize)
if name == "main":
if not os.path.exists(save):
os.makedirs(save)
print(file)
最後報錯為:
C:\ProgramData\Anaconda3\python.exe D:/code/Test/test1/imgsize.py
Traceback (most recent call last):
File "D:/code/Test/test1/imgsize.py", line 13, in
img = Image.open("imgPath")
File "C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py", line 3092, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'imgPath'