Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53904
| Subject | Re: a gift function and a question |
|---|---|
| From | Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> |
| Date | 2013-09-10 10:56 +0430 |
| References | <1378757459.6005.55.camel@debian> <1378758025.32118.19881065.6BD771B7@webmail.messagingengine.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.200.1378794396.5461.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: a gift function and a question Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-09-10 10:56 +0430
csiph-web