[Tutor] Convert string to long

tee chwee liong tcl76 at hotmail.com
Thu Feb 24 03:17:55 CET 2011


hi, 
 
is there a way to convert from string to long? for eg: i want to concatenate all the arrays into data and make it same type (long) as data1. 
 
####code:
a='0x'
array0 = '00000018000004000000000000000000'
array1 = '00000000000000000000000000000000'
array2 = 'fe000000000000000000000000000000'
array3 = '00000000000000000000000000ffffff'
data = a+array0+array1+array2+array3
print data
print type(data)
data1 = 0x0000001800000400000000000000000000000000000000000000000000000000fe00000000000000000000000000000000000000000000000000000000ffffff
print type(data1)
 
###result:
0x0000001800000400000000000000000000000000000000000000000000000000fe00000000000000000000000000000000000000000000000000000000ffffff
<type 'str'>
<type 'long'>
######
 
thanks
tcl 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110224/0e909f72/attachment.html>


More information about the Tutor mailing list