Using Python scripts create dynamic html file -
using below python scripts can able create html file set variables(a,b,c,d) global.i want run script dynamically, don't set variables globally ,for eg: if didn't set value of "a" global throwing error "global 'a' not defined".so please let me know python scripts dynamically taking values , convert them in html table.
import html import html2 html2 import * #print #print b file = open('out.html', 'w') table_data = [ ['s.no', 'testcase - id', 'result'], ['1', a, b], ['2', c, d], ] htmlcode = html.table(table_data) c=htmlcode print htmlcode file.write(c)
table_data needs a, b, etc. defined. incorporates values new global.
this has otherwise nothing html.table(); table_data list cannot defined stands without a , b being defined well.
if want a, b, c , d used parameters module, need make function:
def create_table(a, b, c, d): table_data = [ ['s.no', 'testcase - id', 'result'], ['1', a, b], ['2', c, d], ] return html.table(table_data) now can call create_table() different parameters.
Comments
Post a Comment