I am using Python 2.7 and i try to print Arabic strings like these
print "ذهب الطالب الى المدرسة"
it's give the following output:
ط°ظ‡ط¨ ط§ظ„ط·ط§ظ„ط¨ ط§ظ„ظ‰ ط§ظ„ظ…ط¯ط±ط³ط©
The purpose is to print the text correctly, and not how to print each line. So, how can I print the string or content of text file correctly in its original form? like:
ذهب الطالب الى المدرسة
by this module you can correct your text shape an direction. just install pips and use it.
# install: pip install --upgrade arabic-reshaper
import arabic_reshaper
# install: pip install python-bidi
from bidi.algorithm import get_display
text = "ذهب الطالب الى المدرسة"
reshaped_text = arabic_reshaper.reshape(text) # correct its shape
bidi_text = get_display(reshaped_text) # correct its direction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With