pip install Pygments
python
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
python
python
code = '''
def hello_world():
print("Hello, world!")
hello_world()
'''
python
code = '''
def hello_world():
print("Hello, world!")
hello_world()
'''
with open('highlighted_code.html', 'w') as f: