标签:str tmp range usr end import int python ima
#!/usr/bin/env python
from PIL import Image
img = Image.open("./screen.png")
maps = [[] for i in range(11)]
for i in range(11):
for j in range(11):
maps[i].append(0)
PURPLE = (197,61,255,255)
RED = (230, 69, 115,255)
BLUE = (74,190,255,255)
GREEN = (107,202,33,255)
YELLOW = (255,186,16,255)
COLORS = [PURPLE, RED, BLUE, GREEN, YELLOW]
for i in range(1, 11):
for j in range(1, 11):
x = 104 + 144 * (j - 1)
y = 945 + 144 * (i - 1)
c = img.getpixel((x, y))
if c in COLORS:
maps[i][j] = COLORS.index(c) + 1
f = open(‘maps.rslt‘, ‘w‘)
for i in range(1, 11):
tmp = ‘‘
for j in range(1, 11):
tmp += str(maps[i][j]) + ‘ ‘
f.writelines(str(tmp))
f.write(‘\n‘)
f.close()
print(‘maps.rslt Generate DONE.‘)
标签:str tmp range usr end import int python ima
原文地址:http://www.cnblogs.com/fish7/p/6927006.html