CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
17
Task/Create-an-HTML-table/Python/create-an-html-table-1.py
Normal file
17
Task/Create-an-HTML-table/Python/create-an-html-table-1.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import random
|
||||
|
||||
def rand9999():
|
||||
return random.randint(1000, 9999)
|
||||
|
||||
def tag(attr='', **kwargs):
|
||||
for tag, txt in kwargs.items():
|
||||
return '<{tag}{attr}>{txt}</{tag}>'.format(**locals())
|
||||
|
||||
if __name__ == '__main__':
|
||||
header = tag(tr=''.join(tag(th=txt) for txt in ',X,Y,Z'.split(','))) + '\n'
|
||||
rows = '\n'.join(tag(tr=''.join(tag(' style="font-weight: bold;"', td=i)
|
||||
+ ''.join(tag(td=rand9999())
|
||||
for j in range(3))))
|
||||
for i in range(1, 6))
|
||||
table = tag(table='\n' + header + rows + '\n')
|
||||
print(table)
|
||||
Loading…
Add table
Add a link
Reference in a new issue