generate HTML
Jeffrey Schwab
jeff at schwabcenter.com
Mon Nov 14 10:38:46 EST 2005
s99999999s2003 at yahoo.com wrote:
> hi
> i have fucntion that generates a HTML page
>
> def genpage(arg1,arg2):
> print ''' <div align="right"><font size="-1">BLAH BLAH.....%s %s
> ''' % (arg1, arg2)
>
> print ''' <table> ....blah blah... %s %s
>
> </table>''' % (arg1,arg2)'
>
> The func is something like that, alot of open''' and closing ''' triple
> quotes. anyway, i wish to print all these into a HTML output file so
> that when i click on it, it shows me the html page. How can i do that?
>
> i tried
> f = open("output.html","w")
> f.write ( 'print '''<div align ....
>
> I am stuck at above after doing a lot of f.write for every line of HTML
> . Any betterways to do this in python?
>
> something like here documents in a shell script where it can also be
> directed to a file.
> thanks
>
Why not just redirect the output of your Python script from the shell?
E.g.:
python generate_html.py > output.html
More information about the Python-list
mailing list