鱼C论坛

 找回密码
 立即注册
查看: 1428|回复: 2

[已解决]零基础学习PYTHON第54讲课后练习题目

[复制链接]
发表于 2019-11-18 23:02:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
from easygui import *
from urllib import *
catsize=multenterbox('please input the size of cat','download a cute cat',['width','height'],[400,600])
while 1:
    try:
        width=int(catsize[0].strip())
        height=int(catsize[1].strip())
    except:
        catsize=multenterbox('the size should be int ','download a cute cat',['width','height'],catsize)
    if isinstance(catsize[0],int) and isinstance(catsize[1],int):
        break
response=request.urlopen("http://placekitten.com/g/%d/%d" % (catsize[0],catsize[1])
add=fileopenbox('please choice a place to save cute cat','return is a way')
fileformat='%s/cat_%d_%d.jpg'%(add,catsize[0],catsize[1])
with open(fileformat,'wb') as f:
    f.write(response.read())


报错:
File "<ipython-input-3-856134672d1f>", line 13
    add=fileopenbox('please choice a place to save cute cat','return is a way')
      ^
SyntaxError: invalid syntax

请高手指点
最佳答案
2019-11-18 23:19:05
response=request.urlopen("http://placekitten.com/g/%d/%d" % (catsize[0],catsize[1])最后少一个右括号
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-11-18 23:19:05 | 显示全部楼层    本楼为最佳答案   
response=request.urlopen("http://placekitten.com/g/%d/%d" % (catsize[0],catsize[1])最后少一个右括号
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-11-19 19:35:34 | 显示全部楼层
response=request.urlopen("http://placekitten.com/g/%d/%d" % (catsize[0],catsize[1]))

少了一个右括号,帮你补上了

  1. from easygui import *
  2. from urllib import *
  3. catsize=multenterbox('please input the size of cat','download a cute cat',['width','height'],[400,600])
  4. while 1:
  5.     try:
  6.         width=int(catsize[0].strip())
  7.         height=int(catsize[1].strip())
  8.     except:
  9.         catsize=multenterbox('the size should be int ','download a cute cat',['width','height'],catsize)
  10.     if isinstance(catsize[0],int) and isinstance(catsize[1],int):
  11.         break
  12. response=request.urlopen("http://placekitten.com/g/%d/%d" % (catsize[0],catsize[1]))
  13. add=fileopenbox('please choice a place to save cute cat','return is a way')
  14. fileformat='%s/cat_%d_%d.jpg'%(add,catsize[0],catsize[1])
  15. with open(fileformat,'wb') as f:
  16.     f.write(response.read())
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-20 11:21

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表