Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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!)
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #format #binary #string #python
ADD COMMENT
Topic
Name
8+4 =