2.4.3.24. Python script does not output Cyrillic

If the Python script does not output lines containing Cyrillic characters, make changes to it and format the output by analogy with the examples below.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
 
# enable debugging
import cgitb
cgitb.enable()
 
print "Content-Type: text/html;charset=utf-8"
print
 
print "Hello World!"
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
 
# enable debugging
import cgitb
cgitb.enable()
 
import sys
import codecs
 
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
 
print("Content-Type: text/html; charset=utf-8")
print()
print('Hello World!')
Content