strings problem
Jimmy verma
jim_938 at hotmail.com
Fri Jul 4 13:41:56 EDT 2003
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
Your suggestions will be welcomed.
Thanks a lot.
Regards,
Jim
_________________________________________________________________
Looking for love? Yearning for friendship? http://www.msn.co.in/Romance/
You're in the right place.
More information about the Python-list
mailing list