pythonchallenge--7

import Image
im = Image.open('oxygen.png')
print ('image information:',im.format,im.size,im.mode)
y_begin = 0
while True:
    p = im.getpixel((0,y_begin))
    if p[0] == p[1] == p[2]:
        break
    y_begin += 1
x_end = 0
while True:
    p = im.getpixel((x_end,y_begin))
    if not p[0] == p[1] == p[2]:
        break
    x_end += 1
print('Y first corrdinate:',y_begin,'X last coordinate:x_end:',x_end)
msg = []
for i in range(0,x_end,7):
    p = im.getpixel((i,y_begin))
    msg.append(chr(p[0]))
print(''.join(msg))
msg = [105, 110, 116, 101, 103, 114, 105, 116, 121]
print(''.join([chr(x) for x in msg]))

你可能感兴趣的:(python)