为了账号安全,请及时绑定邮箱和手机立即绑定

求教:第4行一直提示缺少引号,何解?

求教:第4行一直提示缺少引号,何解?

22with33 2018-08-01 12:58:40
def _init(self,items = {}):                 """Optionally pass in an inital dictionary of items"""                 if type(items) != type({}):                         raise TypeError("Fridge requires a dictonary but was given                                         %s " %type(items))                 self.items = items
查看完整描述

4 回答

已采纳
?
大咪

TA贡献785条经验 获得超332个赞

def _init(self, items={}):
    """Optionally pass in an inital dictionary of items"""
    if type(items) != type({}):
        raise TypeError("Fridge requires a dictonary but was given \
                        % s " %type(items))
        self.items = items


查看完整回答
1 反对 回复 2018-08-01
  • 22with33
    22with33
    谢谢您的回答, 我想请问 占位子的百分号要转义吗?
  • 大咪
    大咪
    那个不是转义。。。那个就是换行的意思
  • 大咪
    大咪
    或者还有一种方式,你把后面的引号补全就行了,当然下面那行也要补全前面的引号 r("Fridge requires a dictonary but was given" " % s " %type(items))
?
至北

TA贡献2条经验 获得超1个赞

第4行和第5行放在同一行试下

查看完整回答
反对 回复 2018-08-01
  • 4 回答
  • 0 关注
  • 1792 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信