-2

i want to print my user variable from my python script to a html document and this is the way I have to do this. How do i go about doing it?

my_python.py

user = "myname"
with open("../../html/forms/output.html") as output:
    print(output.readlines())

output.html

<h1>{user}</h1>

EXPECTED OUTPUT :
<h1>myname</h1>

ACTUAL OUTPUT :
<h1>{user}</h1>
Andrej Kesely
  • 118,151
  • 13
  • 38
  • 75
Kapil
  • 125
  • 1
  • 6

1 Answers1

0

f-string is a syntax and not an object, and as a result - You can't convert a string to f-string.

If you know the names of the "variables" inside your template file, you can do:

output.read().format(user=user)
Or Y
  • 1,923
  • 1
  • 15