Generate HTML with Python

0

I'm trying to generate HTML with Python, what I want to show is just a string, but for some reason it does not take into account the string, I hope you can help me

def html_create(self,result):
    template = open("template.html","r")
    output = open("us.html","w")
    text = template.read().format(get_result = result)
    html = output.write(text)
    template.close()
    output.close() 

& in my temple I recive it in the following way

<p> (get_result) </p>   
    
asked by Pony94 16.04.2018 в 17:29
source

1 answer

1

Your code works. I've tried it this way:

File "html.py":

def html_create(result):
    template = open("template.html","r")
    output = open("us.html","w")
    text = template.read().format(get_result = result)
    html = output.write(text)
    template.close()
    output.close()

html_create("hola mundo")

Entry file "template.html":

<p>{get_result}</p>

Output file "us.html":

<p>hola mundo</p>
    
answered by 17.04.2018 / 12:04
source