[Tutor] Convert string to long

tee chwee liong tcl76 at hotmail.com
Thu Feb 24 15:03:32 CET 2011


>>> '0x' + hex(543)[2:].zfill(5)
'0x0021f'

this is a good way but it's still in string format. but if i convert it to long, then the leading 0s will be truncated. i guess can't have it both way. 
 
 
 

 
 

_______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110224/a7e024c9/attachment.html>


More information about the Tutor mailing list