def rgb2hex(r,g,b):
    """ Convert between RGB [0-255] and hex string """
    xr = hex(r)[2:]
    xg = hex(g)[2:]
    xb = hex(b)[2:]
    sr = '0'+str(xr) # can be 0x1 instead of 0x01
    sg = '0'+str(xg)
    sb = '0'+str(xb)
    return "#"+sr[-2:]+sg[-2:]+sb[-2:]