any function to fill zeros to the right?? zfill??

Christian Heimes lists at cheimes.de
Wed Aug 13 21:14:23 EDT 2008


Johnny wrote:
> if I want to fill zeros to the right, what function can help??
> ex:
> '1.23'=>'1.2300'
> but '1.23'.zfill(6)=>'001.23'

Use string formatting:

 >>> "%0.6f" % 1.5
'1.500000'

Christian




More information about the Python-list mailing list