python challenge 16网址:www.pythonchallenge.com/pc/return/mozart.html
打开页面源码发现一句提示:let me get this straight,提示说把它弄直,图片里面杂乱无章的点很明显有很多是品红色的短线,把图按行平移,使得红线对齐。
源代码为:
import Image, ImageChops image = Image.open("mozart.gif") magic = chr(195) for y in range(image.size[1]): box = 0, y, image.size[0], y + 1 row = image.crop(box) bytes = row.tostring() i = bytes.index(magic) row = ImageChops.offset(row, -i) image.paste(row, box) image.save("new.gif")