2
def tohex(r, g, b):
#your code here :)
def hex1(decimal):
if decimal < 0:
return '00'
elif decimal > 255:
return 'FF'
elif decimal < 17:
return '0'+ hex(decimal)[2:]
else:
return inthex(decimal)[2:]
return (hex1(r) + hex1(g) + hex1(b)).upper()
print rgb(16 ,159 ,-137)
私は16進数を得るための新しい方法を定義します。しかし、(16,159、-137)になると、019F00
の代わりにが得られます。余分なものがある理由接頭辞 `0x 'なしで16進数にする方法
の可能性の重複(https://stackoverflow.com/questions/16414559/how-to-use-hex-without-0x-in-python) –