How can I delete all full-black images from a folder by python : After cropping and saving images, I found that there are many full black images (RGB = 0,0,0). I want to delete these images

The followings are the codes I have tried

```
import os, glob
from PIL import image

def CleanUp_images():
    for filename in glob.glob('/Users/Xin/Desktop/TestFolder/*.jpg'):
        im = Image.open(filename)
        pix = list(im.getdata())
        if pix == [(0,0,0)]:
            os.remove(im)

CleanUp_images()

```

However, the above codes didnt work out
Can anyone give me a help?
thanks a lot!!!