+ 1
Why does 0x1=1 in python
sorry that Im a beginner I tried---> print(0x1) in python , where x is a letter before y, then it output '1' (me:????) So what does that '0xk' meaning for , where k is a constant Cause the result of: print(1xk) will always be 'k' I'm just a little bit interesting about it Thx a lot if any help~
2 Réponses
+ 5
0x is the prefix for literal hexadecimal...
0x1 (hexa) == 1 (decimal)
0xf (hexa) == 15 (decimal)
0xff (hexa) == 255 (decimal)
+ 1
Oic
That's really a cool thing for me!
I'm interested what to do if I want to turn from hexadecimal to decimal or turn from decimal to bincimal~
Thxxxxxxx!