Converting a RGB color tuple to a six digit code

Use the format operator %:

>>> '#%02x%02x%02x' % (0, 128, 64)
'#008040'

Note that it won’t check bounds…

>>> '#%02x%02x%02x' % (0, -1, 9999)
'#00-1270f'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)