I have a html boiler plate in which i want to put some variables later when i get it so just paste the html as a string and insert variables in that but doing this giving me error that string literal is undetermined this is logically a string
txt = f"
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title}</title>
</head>
<body>
</body>
</html>"
CodePudding user response:
You should use """ your string here """
if you intend to write a string on multiple lines in python, so your txt variable should belike :
txt = f"""
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title}</title>
</head>
<body>
</body>
</html>"""
CodePudding user response:
Multi-line strings need triple strings, so you could do
txt = f"""
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title}</title>
</head>
<body>
</body>
</html>"""