[Tutor] Concatenating string

tee chwee liong tcl76 at hotmail.com
Tue Feb 22 14:46:22 CET 2011


hi, 
 
>>> bin(0xff0)
'111111110000'
>>> bin(0xff1)
'111111110001'
>>> a=bin(0xff0)+bin(0xff1)
>>> a
'111111110000111111110001'
>>> b=0xff0
>>> c=0xff1
>>> d=b+c
>>> d
8161
>>> bin(d)
'1111111100001'
 
question: 
1) why is it that a and d values are different? i'm using Python 2.5. 
2) how to convert hex to bin in Python 2.5?
 
 
thanks
tcl 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110222/334e5091/attachment.html>


More information about the Tutor mailing list