0

I want to print some Marathi language characters in Python. Here's my code.

print(u'*********************************भाई पायथॉन शिकतोय***************************')
print("*********************************************************************************************************")

The output I get is: Output of code

What do I need to change to make it work?

  • 1
    The problem is not with python, but rather the product you're using to display the python output. In your example it looks like you're using the windows command prompt. This answer might help, or at least point you in the right direction: https://stackoverflow.com/a/55674760/3308951 – SyntaxVoid Mar 11 '20 at 13:37
  • Use font capable of rendering Devanagari. That weird characters are _Glyph 0_ (the .notdef glyph), see also ['cmap' Table](https://learn.microsoft.com/en-us/typography/opentype/spec/recom#glyph-0-the-notdef-glyph). Try [Windows Terminal](https://learn.microsoft.com/en-us/windows/terminal/). – JosefZ Jan 30 '21 at 23:15

2 Answers2

0

Please try with encoding at top of script as 'utf-8'

# -*- coding: utf-8 -*-
print(u'*********************************भाई पायथॉन शिकतोय***************************')
print("*********************************************************************************************************")
0

With latest python version you don't need u' with print keyword. Try direct with print.

>>> # -*- coding: utf-8 -*-
>>> print(f"{'*'*40} भाई पायथॉन शिकतोय {'*'*40}") 
**************************************** भाई पायथॉन शिकतोय ****************************************