import Image,ImageDraw
def connect_dots():
im=Image.open('good2.jpg')
#print im.mode
src=open('E:\\python challenge\\first.txt','rb').read()
list=re.findall('\d+',src) #get all the numeric values -->return list
list=tuple(map(int,list)) # convert str value in list to int then change the list to tuple type
draw=ImageDraw.Draw(im)
color=(115,115,255)
draw.point(list,color)
im.save('good2.jpg')
connect_dots()
运行之后得到的图像为一头牛。把牛的英文单词(cow or bull)输入URL中我们就可以进入下一头了。
上面的图片看起来不是太清楚,我们可以用draw_line来实现。就是把这些坐标用线连起来。首先先把first,second这两个里面的数据放到两个list里面。