Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I include python script in a HTML file?

Tags:

python

html

How do I put this python script:

a = ['f','d','s','a']
x = -1
scope = vars()
for i in a:
    scope['x']+=1
    print a[x]

inside of a html file?

like image 690
newbie pisan Avatar asked Feb 03 '23 00:02

newbie pisan


1 Answers

Something like this, if you want to create an html, not necessarily display it:

 html_file = open('namehere.html','w')
 a = ['f','d','s','a']
 x = -1
 scope = vars()
 data = ''
 for i in a: #TIP: use a generator
     scope['x']+=1
     data += a[x]
     data += '\n'
 html_file.write(data)
 html_file.close()
like image 132
Jorge Guberte Avatar answered Feb 05 '23 14:02

Jorge Guberte