Hallo, ich möchte mit python eine html datei schreiben. Ungefähr so:
1 2 3 4 5 6 7 8 9 10 11 12 | f = open("test.html", "w") f.write("<!DOCTYPE html>") f.write("<html lang="de">") f.write(" <head>") f.write(" <meta http-equiv="content-type" content="text/html; charset=UTF-8">") f.write(" <title>Test</title>") f.write(" </head>") f.write(" <body style="background-color:black;"> ") f.write(" <h1 style="color:white; font-size:35px" align="center">Test</H1>") f.write(" </body>") f.write("</html>") f.close() |
Jedoch kommt immer dieser Error:
1 2 3 | f.write("<html lang="de">") ^ SyntaxError: invalid syntax |
bei allem anderen auch. War eigentlich klar das das so kommt.
Wie löst man das am besten? Möchte bei python bleiben, da ich später noch ein paar f strings hinzufügen werde.