[Tutor] Convert string to long

tee chwee liong tcl76 at hotmail.com
Thu Feb 24 12:50:10 CET 2011


> int(s,16) for a hex string
> 

great but the leading zeroes are being truncated. 
i want it to be: 0x0000001800000400000000000000000000000000000000000000000000000000L

>>> array0='00000018000004000000000000000000'
>>> array1='00000000000000000000000000000000'
>>> array=array0+array1
>>> a=int(array,16)
>>> print a
647038726439367532107969464256319505531941876229785714677657987186688
>>> print hex(a)
0x1800000400000000000000000000000000000000000000000000000000L
>>> 
 
pls advise.  		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110224/246758ee/attachment.html>


More information about the Tutor mailing list