Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53904 > unrolled thread
| Started by | Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> |
|---|---|
| First post | 2013-09-10 10:56 +0430 |
| Last post | 2013-09-10 10:56 +0430 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: a gift function and a question Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-09-10 10:56 +0430
| From | Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> |
|---|---|
| Date | 2013-09-10 10:56 +0430 |
| Subject | Re: a gift function and a question |
| Message-ID | <mailman.200.1378794396.5461.python-list@python.org> |
I completed my two functions, i say may be poeple can use them:
######################################33
def integerToPersian(number):
listedPersian = ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹']
listedEnglish = ['0','1','2','3','4','5','6','7','8','9']
returnList = list()
for i in list(str(number)):
returnList.append(listedPersian[listedEnglish.index(i)])
return ''.join(returnList)
def persianToInterger(persianNumber):
listedTmpString = list(persianNumber.decode("utf-8"))
returnList = list()
for i in listedTmpString:
returnList.append(unicodedata.digit(i))
return int (''.join(str(x) for x in returnList))
#######################################33
On Mon, 2013-09-09 at 16:20 -0400, random832@fastmail.us wrote:
> On Mon, Sep 9, 2013, at 16:10, Mohsen Pahlevanzadeh wrote:
> > My question is , do you have reverse of this function? persianToInteger?
>
> The int constructor is able to handle different forms of decimal
> numerals directly:
>
> >>> int('\u06f3\u06f4\u06f5\u06f5')
> 3455
Back to top | Article view | comp.lang.python
csiph-web