大家好,我是羽峰,今天给大家分享点有意思的事情,每年的520,521,又要到了。给女朋友买礼物是否伤透了你的脑筋。哈哈,来,让我教你,一个python搞定她,如果想表白,用这个更显的你牛逼。先来上图

有没有很棒呢?想不想学呢?哈哈

当然女朋友可能没有的,但是网上那么多漂亮小姐姐还是有的,所以先爬取了一些小姐姐照片吧

是不是很可以。爬取完之后,我们就来正式的表白墙了,首先准备你要的效果样版

程序里就是一个二维数组,

#521
Logo_Image_521 = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,0],
[0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0],
[0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0],
[0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,0],
[0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0],
[0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0],
[0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
]
#心
Logo_Image_herat = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0],
[0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0],
[0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,0],
[0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0],
[0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
]

当然你可以自己设计自己的logo,所有的情话都用女生照片写出来是不是很棒 哈哈

接下来就是放置照片了

for y in range(1,11):
	for x in range(1,16):
		if Logo_Image_herat[y][x] == 1:
			try:
				fromImage = Image.open(r"./image/%s.jpg" %str(ms*(y-1)+x))
				fromImage = fromImage.resize((100,100),Image.ANTIALIAS)
				toImage.paste(fromImage,((x-1)*mw,(y-1)*mw))
			except IOError:
				pass
toImage.show()
toImage.save('./img/ta.png')

结果就是

不花一分钱,给她一个不一样的惊喜,有没有哈哈。当然除了这个还有

还有这种

当然,还可以是动画

哈哈,怎么样,应该会是一份不错的惊喜吧,所有代码我已打包,欢迎关注“羽峰码字”公众号,回复“520”即可获取。

我是羽峰,公众号“羽峰码字”,欢迎来“撩”哈。

 

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐