[Tutor] Help me out please
alan.gauld at yahoo.co.uk
Tue Jul 19 09:57:39 EDT 2016
On 19/07/16 12:31, Marc Sànchez Quibus wrote:
> and now I need some help to finish my project.
> I have two scripts, one of them in python (the main script) and the other
> by Github. I need to change a variable inside this html script. I was
> wondering wether I could change this variable from my python script or not.
> Is there some way to do it?
The easiest way is to put the entire html code into a string
inside a module:
# file: myhtml.py
html = """
Then import that and use string formatting to insert the variable
myvar = "World"
print myhtml.html % myvar
Instead of printing you could overwrite the original html file.
Or you could write a web based app using a framework like Flask
or Pylons and call your myscript.py from a web url and get it
to just serve the html string directly.
We don't know enough about your system and how the two
scripts are related to say more than that. But it might
give you some ideas.
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor