Basically, what I want to know is, is there a simpler way to write this that does not require the import os module?
I want to create a simple webpage from Python using an HTML file. And while this does exactly what I want, I cannot seem to come up with a simple/basic way, or a way that does not involve the import os module.
import os
name = input("Enter your name here: ")
persona = input("Write a sentence or two describing yourself: ")
with open('mypage.html', 'rt') as file:
with open('temp_mypage.html', 'wt') as new:
for line in file:
line = line.replace('some_name', name)
line = line.replace('some_persona', persona)
new.write(line)
os.remove('mypage.html')
os.rename('temp_mypage.html', 'mypage.html')
HTML code:
<html>
<head>
<body>
<center>
<h1>
some_name
# input into the file
</h1>
</center>
<hr />
some_persona
<hr />
</body>
</html>