반응형
[python] How to write to an HTML file in Python
https://www.kite.com/python/answers/how-to-write-to-an-html-file-in-python
USE open() AND file.write() TO WRITE TO AN HTML FILE
Use open(file, mode) with mode as "w" to create a new HTML file file or write to an existing one. Use file.write(data) to write data to the file. Use file.close() to close the file after writing.
text = '''
<html>
<body>
<h1>Heading</h1>
</body>
</html>
'''
file = open("sample.html","w")
file.write(text)
file.close()
SAMPLE.HTML
<html>
<body>
<h1>Heading</h1>
</body>
</html>
반응형
'프로그래밍 > Python' 카테고리의 다른 글
[python] conda update (0) | 2022.03.18 |
---|---|
[python] mpld3를 이용해서 python의 그림을 웹에 올려보자. (0) | 2022.02.25 |
[python] mpld3 - Bringing Matplotlib to the Browser (0) | 2022.02.23 |
[python] networkx - Graph Layout (0) | 2022.02.16 |
[python] Choosing Colormaps in Matplotlib. cm (0) | 2022.02.16 |