wrapper = """<html>
<head>
</head>
<body>
<table style="height: 100px;" width="500">
<tbody>
<tr>
<td rowspan="3"><a id="imgrec1" href="http://www.w3.org"><img src="%s" alt="Smiley face" width="50" height="100" /><br /><br /></a></td>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
<tr>
<td rowspan="3"><a id="imgrec1" href="http://www.w3.org"><img src="%s" alt="Smiley face" width="50" height="100" /><br /><br /></a></td>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
<td>%s</td>
</tr>
<tr>
</tbody>
</table>
</body>
</html>"""
str=""
for i in reclist[:2]:
str=str + "I[\"" + i + "\"]," + "T[\"" + i + "\"]," +"R[\"" + i + "\"]," +"P[\"" + i + "\"],"
str = str[:-1]
print str
whole = wrapper % (str)
Output: I["M1"],T["M1"],R["M1"],P["M1"],I["M2"],T["M2"],R["M2"],P["M2"]
whole = wrapper % (str)
TypeError: not enough arguments for format string
정확히 8 % s 및 str
도 8 개 튜플을 가지고 있지만 여전히 경우, 대신 STR의 오류 TypeError: not enough arguments for format string.
파이썬 형식 오류 :의 경우 형식 문자열에 대한 충분한 인수 문자열 %의 <code>wrapper</code>으로
을 보여주는이 내가 사용한다
whole = wrapper %
(I["M1"],T["M1"],R["M1"],P["M1"],I["M2"],T["M2"],R["M2"],P["M2"])
잘 작동하고있다.
이 문제는 stackoverflowstackoverflow을 참조하지만 도움이되지 않았습니다.
간단한 'wrapper = "..."를 게시하십시오. str = ...; 출력 = wrapper % str' 예제. – VPfB