In python2.7"{:010b}".format(25) would return'0000011001' giving a 10 bit binary string representation of the number 25. In python2.6 the same command returnsValueError: zero length field name in format. Is there a different way doing simple formated conversions for python2.6
1 Answer1
Use theformat() function, it's easier (no need for the template placeholder parts, only the formatter string is needed):
format(25, '010b')but you ran into a simplification in Python 2.7, where you don't have to specify the positional parameter. The 2.6 equivalent is:
"{0:010b}".format(25)Comments
Explore related questions
See similar questions with these tags.