Answers for "format binary string python"

2

format binary string python

x = 10
print(format(x, '#b')) # 0b1010
print(format(x, 'b')) # 1010
x= 0xF
print(format(x, 'b')) # 1111
print(f'{x:b}') # 1111 (If you knew this format, you are Python Ninja!)
Posted by: Guest on July-20-2020
0

format binary string python

>>> format(14, '#010b')
'0b00001110'
Posted by: Guest on July-20-2020

Code answers related to "format binary string python"

Python Answers by Framework

Browse Popular Code Answers by Language