python色RGB変換色16進数を実現

385 ワード

python色RGB変換色16進数を実現
超単純な実装プロセス
#coding:utf-8

def RGB_to_Hex(tmp):
    rgb = tmp.split(',')# RGB      
    strs = '#'
    for i in rgb:
        num = int(i)# str int
        # R、G、B     16         
        strs += str(hex(num))[-2:].replace('x','0').upper()
        
    return strs

print(RGB_to_Hex('255,255,255'))