bonfy / problems

record problems I have met and solved
2 stars 1 forks source link

Python的进制转换 及 位运算 #11

Open bonfy opened 7 years ago

bonfy commented 7 years ago

Python的进制转换 及 位运算

bonfy commented 7 years ago

https://wiki.python.org/moin/BitManipulation https://www.coder4.com/archives/3711 http://www.runoob.com/python/python-operators.html

bonfy commented 7 years ago
# 10进制 -〉 2进制
>>> bin(10)
'0b1010'
# 2进制 -〉 10进制
>>>int(bin(10), 2)
10
>>>int('0101', 2)
5