HTML_BODY= """ <html>
<head>
<title></title>
<style>
table {color: #333;font-family: calibri; width: 80%%;border-collapse:collapse; border-spacing: 0;}
td, th { border: 1px solid #CCC;width:100px; height: 30px; }
th {background: #F3F3F3;font-weight: bold;font-size: 13px;}
td {background: #FAFAFA;text-align: center; font-size: 12px;}
</style>
</head>
<body>
<table>
<tbody>
<tr>
<th>
S.No.</th>
<th>
Scenario Name</th>
<th>
Total Test Cases</th>
<th>
Passed Test Cases</th>
<th>
Failed Test Cases</th>
</tr>
<tr>
<td>
1</td>
<td>
%s%</td>
<td>
%s%</td>
<td>
<span style="color:#008000;">%s%</span></td>
<td>
<span style="color:#ff0000;">%s%</span></td>
</tr>
</tbody>
</table>
<p>
</p>
<table>
<tbody>
<tr>
<th>
Total Scenario</th>
<th>
Total Test Cases</th>
<th>
Passed Test Cases</th>
<th>
Failed Test Cases</th>
</tr>
<tr>
<td>
%s%</td>
<td>
%s%</td>
<td style="color:#008000;">
%s%</td>
<td style="color:#ff0000;">
%s%</td>
</tr>
</tbody>
</table>
<p>
</p>
</body>
&#34;&#34;&#34; %(自.__流动性,自.__ totalflowtestcases,自.__ flowtestpass,自.__ flowtestfail,自.__ alltestcases,自.__ alltestcases,自.__ testpass,自.__ testfail)
然后我收到错误:ValueError:不支持的格式字符&#39;&lt;&#39; (0x3c)在索引3
答案 0 :(得分:3)
问题是这一行:
%s%</td>
假设 %<
是Python解释器的格式字符串。如果要在格式字符串中打印%
符号,请使用%%
,即:
%s%%</td>