下载一只猫

 1 import easygui as g
 2 import urllib.request
 3 
 4 title = '下载一只猫'
 5 msg = '请输入猫的尺寸'
 6 values = ('','')
 7 
 8 interface = g.multenterbox(msg,title,values)
 9 size = interface[0]+'/'+interface[1]
10 
11 response = urllib.request.urlopen('http://placekitten.com/'+size).read()
12 file_path = g.diropenbox(msg='请选择存放猫的文件夹') + '喵.jpg'
13 
14 with open(file_path,'wb') as f:
15     f.write(response)
原文地址:https://www.cnblogs.com/themost/p/6637969.html