Print Urdu/Arabic Language in Console (Python)

2019-07-09 12:41发布

问题:

I am a newbie and i don't know how to set my console to print urdu / arabic characters i am using Wing IDE when i run this code

print "طجکسعبکبطکسبطب"

i get this on my console

طجکسعبکبطکسبطب

回答1:

You should encode your string arguments as unicode UTF-8 or later. Wrap the whole code in unicode, and/or mark individual string args as unicode (u'your text') too.

Additionally, you should make sure that unicode is enabled in your terminal/prompt window too.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

arabic_words = u'لغت العربیه'

print arabic_words