Skip to content

Instantly share code, notes, and snippets.

@ekm507
ekm507 / convert_string_numbers_to_persian.py
Created May 9, 2021 20:36
تبدیل اعداد انگلیسی در رشته به فارسی در پایتون
# نگاشت اعداد انگلیسی به فارسی
E2P_map = {'1' : '۱', '2' : '۲', '3' : '۳', '4' : '۴', '5' : '۵', '6' : '۶', '7' : '۷', '8' : '۸', '9' : '۹', '0' : '۰' }
# تبدیل اعداد انگلیسی به فارسی در رشته ورودی
def convert_number_to_persian(strIn : str):
a = map(lambda ch: E2P_map[ch] if ch in E2P_map else ch, strIn)
return ''.join(list(a))
@amrza
amrza / run.py
Last active April 11, 2024 07:14
How to write RTL(Arabic/Persian) text on images in python.
# Tested on Python 3.6.1
# install: pip install --upgrade arabic-reshaper
import arabic_reshaper
# install: pip install python-bidi
from bidi.algorithm import get_display
# install: pip install Pillow
from PIL import ImageFont