Python Challenge 16

Source: Internet
Author: User

Previously review: previous article

16th off Address

Open 16 off, but also a strange and many points of the picture, it should be related to the PIL library.

The title of the page is: Let me get the this straight. This is a slang term in English, which means let me make it clear. In this gateway is actually let us put the pixel position of each line after adjusting to it.

Look at this picture, a lot of red dots, and then think of these dots are not what the pixel is special, the pixel value of each row is printed out and found that each row has a continuous 5 pixel value of 195.

It then shifts the pixels of each row, moves the pixel value 195 to the leftmost, and then gets a new picture of it. The following:

That is, the URL of the next pass.

The code is as follows:

1 Importurllib.request as ur2  fromPILImportImage3 4 defMain ():5im = Image.open ("Mozart.gif")6(width,height) =im.size7mode =Im.mode8     Print(Mode)9     Print(im.size)Ten  OneImanswer =image.new (mode, (width,height)) A  -      forYinchRange (height): -pixels = [Im.getpixel ((x, y)) forXinchrange (width)] the         Print(pixels) -          -x = Pixels.index (195) -Newpixels = Pixels[x:width] +Pixels[:x] +  -          forXinchRange (width): + Imanswer.putpixel ((x, y), newpixels[x]) A  atImanswer.save ('16answer.gif') -          -  - if __name__=='__main__': -Main ()

Python Challenge 16

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.