Here is a code that is reading a file for me. But each word of the file is reversed from the original text that I have put in line.txt
file.
line.txt
اور ایک
test.py
import re
f = open("line.txt",encoding="utf-8")
text = f.read()
print(text)
CodePudding user response:
try this https://github.com/mpcabd/python-arabic-reshaper
or
print(text[::-1])
CodePudding user response:
The simple solution is to print the reversed text:
print(text[::-1])
Another solution is to use a bi-directional library python-bidi
from bidi.algorithm import get_display
f = open("line.txt",encoding="utf-8")
text = f.read()
print(get_display(text))