[Tutor] hex output

Alan Gauld alan.gauld at blueyonder.co.uk
Thu Sep 11 22:42:30 EDT 2003

> >>>  import string
> >>>  string.zfill(hex(65)[2:],4)
> '0041'
> The second parameter of string.zfill() specifies the number of
> you want in the string.  If there are fewer digits, the function
> zeros to the left.

The format operator (%) does all of that and is almost certainly
faster. See the earlier messages.

Alan G.

More information about the Tutor mailing list