|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
譬如
- import urllib.request,requests,sys
- import easygui as g
- def Cat():
- title = '撸猫神器'
- X = g.enterbox('请输入宽度像素:',title)
- Y = g.enterbox('请输入长度像素:',title)
- r = requests.get(url = 'http://placekitten.com/g/'+X+'/'+Y)
- if r.status_code == 200:
- response = urllib.request.urlopen('http://placekitten.com/g/'+X+'/'+Y)
- cat_img = response.read()
- with open('cat_'+X+'_'+Y+'.jpg','wb') as f:
- f.write(cat_img)
- if g.ccbox('图片下载完成',title,choices=('继续','退出')):
- Cat()
- else:
- sys.exit()
- else:
- if g.ccbox('没有这个格式的图片',title,choices=('继续','退出')):
- Cat()
- else:
- sys.exit()
- Cat()[p=30, 2, left][/p]
复制代码
按f5运行之后出现空白
你Cat()调用完了,后面的中括号里的[p=30……]是个啥?
直接调用Cat()就有。
- import urllib.request,requests,sys
- import easygui as g
- def Cat():
- title = '撸猫神器'
- X = g.enterbox('请输入宽度像素:',title)
- Y = g.enterbox('请输入长度像素:',title)
- r = requests.get(url = 'http://placekitten.com/g/'+X+'/'+Y)
- if r.status_code == 200:
- response = urllib.request.urlopen('http://placekitten.com/g/'+X+'/'+Y)
- cat_img = response.read()
- with open('cat_'+X+'_'+Y+'.jpg','wb') as f:
- f.write(cat_img)
- if g.ccbox('图片下载完成',title,choices=('继续','退出')):
- Cat()
- else:
- sys.exit()
- else:
- if g.ccbox('没有这个格式的图片',title,choices=('继续','退出')):
- Cat()
- else:
- sys.exit()
- Cat()
复制代码
|
-
运行之后出现空白
|