-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
  • 168,389
  • 15
  • 48
  • 91
Kapil
  • 165
  • 1
  • 9

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
  • 2,088
  • 3
  • 16