简体   繁体   中英

Python: PSP & HTML tables

I have a python psp page code is shown below. Currently it only prints out the characters in single rows of 60, with the character count in the left column.

<table>
<%
s = ''.join(aa[i] for i in table if i in aa)
for i in range(0, len(s), 60):
    req.write('<tr><td><TT>%04d</td><td><TT>%s</TT></td></tr>' % (i+1, s[i:i+60]));
#end
%>
</table>

The problem i am having trouble is with out putting each character in an individual cell rather than a cell of 60 characters. I've tried doing this with the code below, but it prints out a line of 60 characters 60 times.

<table>
<%
s = ''.join(aa[i] for i in table if i in aa)
for i in range(0, len(s), 60):
    req.write('<tr><td>%04d</td>' % (i+1));
    for k in s:
        req.write('<td>%s</td></tr>' % s[i:i+60]);
#end
%>
</table>
for k in s[i:i+60]:
    req.write('<td>%s</td>' % k)
req.write('</tr>')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM