Reputation: 19184
I have a python file test.py
import os
print os.system("dir")
def test():
a = 5 + 6
print a
test()
I want to convert this test.py into HTML file so that I can view the file in HTML browser with same indentation and formats.
Is there any way or module which converts my python file into HTML and vice versa?
Upvotes: 2
Views: 11308
Reputation: 221
I am a bit late to the party, but you can use Jupyter Notebook. Paste your code in a cell and export the notebook as HTML.
Upvotes: 0
Reputation: 224
Do:
<pre>
import os
print os.system("dir")
def test():
a = 5 + 6
print a
test()
</pre>
pre
tag displays text with fixed-width font, and it preserves both spaces and line breaks.
Upvotes: 3