[Tutor] hex output

Erik Price erikprice at mac.com
Thu Sep 11 20:50:03 EDT 2003


On Thursday, September 11, 2003, at 04:42  PM, Alan Gauld wrote:

>>>>>  import string
>>>>>  string.zfill(hex(65)[2:],4)
>> '0041'
>>
>> The second parameter of string.zfill() specifies the number of
> digits
>> you want in the string.  If there are fewer digits, the function
> pads
>> zeros to the left.
>
> The format operator (%) does all of that and is almost certainly
> faster. See the earlier messages.

Not to mention, no offense to the OP, much easier to comprehend.


Erik




More information about the Tutor mailing list