TypeError:在python中设置字符串格式期间,并非所有参数都已转换
知道我为什么会收到这个错误信息吗:TypeError:在python中设置字符串格式期间,并非所有参数都已转换,python,typeerror,Python,Typeerror,知道我为什么会收到这个错误信息吗: editResponsHtml """ % (person, pId) TypeError: not all arguments converted during string formatting? 代码: def editResponse(表单): 全球家庭树 FAMILYTREE.editPerson(int(form.getvalue(“id”).decode('latin-1')),form.getvalue(“firstName”).de
editResponsHtml """ % (person, pId)
TypeError: not all arguments converted during string formatting?
代码:
def editResponse(表单):
全球家庭树
FAMILYTREE.editPerson(int(form.getvalue(“id”).decode('latin-1')),form.getvalue(“firstName”).decode('latin-1')、form.getvalue(“lastName”).decode('latin-1')、form.getvalue(“dYear”).decode('latin-1')、form.getvalue(“mom”).decode('latin-1')、form.getvalue(“dad”).decode('latin-1'))
person=FAMILYTREE.getPerson(form.getvalue(“id”))
返回EditResponseHTML(person,person.fid)
def EDItResponseHTML(个人,pId):
返回u”“”%s sparades
“%”(人,pId)
您正在传入两个值以进行格式化,但只指定一个插槽
插槽计数和参数数必须匹配。为pId
添加插槽或将其从元组中删除:
def editResponsHtml(person, pId):
return u"""<p>%s %s sparades!</p>
""" % (person, pId)
def editResponsHtml(person, pId):
return u"""<p>%s sparades!</p>
""" % (person,)
def editResponseHTML(个人,pId):
返回u“”%s%s斯巴达
“%”(人,pId)
def EDItResponseHTML(个人,pId):
返回u”“”%s sparades
“%”(人)
或者,使用命名插槽和字典:
def editResponsHtml(person, pId):
return u"""<p>%(person)s sparades!</p>
""" % {'person': person, 'pId': pId}
def editResponseHTML(个人,pId):
返回u“”%(个人)的空格
“%{'person':person,'pId':pId}”
它不会抱怨未使用的密钥。返回u”“”%s sparades
return u"""<p>%s sparades!</p>
“%”(人,pId)
您有一个格式说明符(%s
),但有两个值:person
和pId
,您没有说明符,如%d
用于pId
return u"""<p>%s sparades!</p>