Skip to content

Instantly share code, notes, and snippets.

@ekm507
Created May 9, 2021 20:36
Show Gist options
  • Save ekm507/fd57b6082535d12d82433bc7083ce536 to your computer and use it in GitHub Desktop.
Save ekm507/fd57b6082535d12d82433bc7083ce536 to your computer and use it in GitHub Desktop.
تبدیل اعداد انگلیسی در رشته به فارسی در پایتون
# نگاشت اعداد انگلیسی به فارسی
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))
@ekm507
Copy link
Author

ekm507 commented May 9, 2021

تبدیل اعداد انگلیسی در رشته به فارسی در پایتون

@halataa
Copy link

halataa commented Sep 22, 2023

استفاده کردم ممنون :)

@SAMIRKL
Copy link

SAMIRKL commented Jan 6, 2024

Thanks <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment