合天misc100

打开txt文件是一串RGB颜色值

用len(file.readlines()),发现颜色值有61366个,能分解成122*503

 1 from PIL import Image
 2 length = 122
 3 width = 503
 4 pic = Image.new("RGB",(length, width))
 5 file = open('/Users/.../Desktop/misc100.txt')
 6 l = file.readlines()
 7 for y in range (0,width):
 8     i = 1
 9     for x in range (0,length):
10         s = l[(y+1)*122-i]
11         a,b,c = s.split(',')
12         pic.putpixel([x,y],(int(a),int(b),int(c)))
13         i += 1
14 pic = pic.rotate(90)
15 pic.show()

 

你可能感兴趣的:(sc)