How to change the number into the same expression's string and vice versa?

Peter Otten __peter__ at web.de
Mon Jan 19 12:46:33 CET 2015


Jussi Piitulainen wrote:

> Peter Otten writes:

>> >>> "{:o}".format(0xf4)
>> '364'

>> To add a prefix just put it into the format string.
 
> There's also these (in Python 3.2.3):
> 
>   >>> hex(0xf4)
>   '0xf4'

D'oh!




More information about the Python-list mailing list