且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

十六烷基。 RGB - 使用Python的HSV颜色空间转换

更新时间:2023-01-27 11:07:51

问题出在你的dec2hex代码中:

The problem is in your dec2hex code:

def dec2hex(d):
    """return a two character hexadecimal string representation of integer d"""
    r = "%X" % d
    return r if len(r) > 1 else r+r

当值小于16时,你想要这样:

When your value is less than 16, you're duplicating it to get the value, in other words, multiplying it by 17. You want this:

def dec2hex(d):
    """return a two character hexadecimal string representation of integer d"""
    return "%02X" % d