输入:-
CRlist
[['CR', 'FA', 'CL', 'TITLE'], ['409452', 'WLAN', '656885', 'Age out RSSI values from buffer in Beacon miss scenario'], ['379104', 'BT', '656928', 'CR379104: BT doesn\xe2\x80\x99t work that Riva neither sends HCI Evt for HID ACL data nor response to HCI_INQUIRY after entering into pseudo sniff subrating mode.']]
我有以下 pythong 代码来生成 HTML 代码,但它生成了一个不期望的输出,我将数组值 pring 之前似乎有正确的数据,但是在 using.format 时,有些东西变得混乱了..谁能指出什么是错的这里?
for i in range(len(CRlist)):
if i==0:
continue
for j in range(len(CRlist[0])):
print "i"
print i
print "j"
print j
print "CRlist[i][j]"
print CRlist[i][j]//right data here
CRstring += """
<tr>
<td><a href="{CR}">{CR}</a></td>
<td>{FA}</td>
<td>{CL}</td>
<td>{Title}</td>
</tr>""".format(
CR=CRlist[i][j],
FA=CRlist[i][j],
CL=CRlist[i][j],
Title=CRlist[i][j],
)
CRstring += "\n</table>\n"
我对输出的期望,但创建不正确
<tr>
<td><a href="409452">409452</a></td>
<td>WLAN</td>
<td>656885</td>
<td>Age out RSSI values from buffer in Beacon miss scenario</td>
</tr>
..............
实际输出,行单元格数据是多余的
<tr>
<td><a href="409452">409452</a></td>
<td>409452</td>
<td>409452</td>
<td>409452</td>
</tr>
<tr>
<td><a href="WLAN">WLAN</a></td>
<td>WLAN</td>
<td>WLAN</td>
<td>WLAN</td>
</tr>
<tr>
<td><a href="656885">656885</a></td>
<td>656885</td>
<td>656885</td>
<td>656885</td>
</tr>
<tr>
<td><a href="Age out RSSI values from buffer in Beacon miss scenario">Age out RSSI values from buffer in Beacon miss scenario</a></td>
<td>Age out RSSI values from buffer in Beacon miss scenario</td>
<td>Age out RSSI values from buffer in Beacon miss scenario</td>
<td>Age out RSSI values from buffer in Beacon miss scenario</td>
</tr>
<tr>
<td><a href="379104">379104</a></td>
<td>379104</td>
<td>379104</td>
<td>379104</td>
</tr>
<tr>
<td><a href="BT">BT</a></td>
<td>BT</td>
<td>BT</td>
<td>BT</td>
</tr>
<tr>
<td><a href="656928">656928</a></td>
<td>656928</td>
<td>656928</td>
<td>656928</td>
</tr>
<tr>
<td><a href="CR379104: BT doesnΓÇÖt work that Riva neither sends HCI Evt for HID ACL data nor response to HCI_INQUIRY after entering into pseudo sniff subrating mode.">CR379104: BT doesnΓÇÖt work that Riva neither sends HCI Evt for HID ACL data nor response to HCI_INQUIRY after entering into pseudo sniff subrating mode.</a></td>
<td>CR379104: BT doesnΓÇÖt work that Riva neither sends HCI Evt for HID ACL data nor response to HCI_INQUIRY after entering into pseudo sniff subrating mode.</td>
<td>CR379104: BT doesnΓÇÖt work that Riva neither sends HCI Evt for HID ACL data nor response to HCI_INQUIRY after entering into pseudo sniff subrating mode.</td>
<td>CR379104: BT doesnΓÇÖt work that Riva neither sends HCI Evt for HID ACL data nor response to HCI_INQUIRY after entering into pseudo sniff subrating mode.</td>
</tr>
/table>
=========PLlist==========