strings problem

Bob Gailer bgailer at alum.rpi.edu
Fri Jul 4 21:11:14 CEST 2003


At 11:11 PM 7/4/2003 +0530, Jimmy verma wrote:

>Hello *.*
>
>Can you please tell me how can i have the output in no's, instead of 
>string from this program:
>
>#/usr/bin/python
>import re
>import string
>
>def csNumEncode(num):
>    if(num>=-107 and num<=107):
>        return chr(num+139)
>    elif(num>=108 and num<=1131):
>        return chr(((num-108)/256)+247) + chr((num-108)%256)
>    else:
>        print 'do nothing'
>
>re_num = re.compile("\-?[0-9]+(\.[0-9]+)?")
>
>
>def CompileCS(source):
>  result=''
>  for tkn in re.split('[ \n\t]+', source):
>    print "Token: %s"%tkn
>    if re_num.match(tkn):
>        result = result + csNumEncode(string.atoi(tkn))
>    else:
>        raise SyntaxError, "%s is invalid operator"%tkn
>  return result
>
>src1 = '50  800'
>
>t = CompileCS(src1)
>
>print t
>
>
>
>The output is
>
>Token: 50
>Token: 800
>\275\371\264
>
>
>Instead of this i want the output should be in no's like this:
>bdF9B4

When I run this I get:
Token: 50
Token: 800
some graphical characters that don't even copy into the e-mail (whose ord 
values are 189, 249, 180).

I have stared at the desired result bdF9B4 but see no relationship between 
that and '50  800'. What is the relationship (what are you wanting to 
accomplish)?


Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.492 / Virus Database: 291 - Release Date: 6/24/2003


More information about the Python-list mailing list