Check whether the input is a hexadecimal color code.
Matches standard 6-digit hex colors with an optional 2-digit alpha suffix (e.g. #FF0000 or #FF0000FF).
#FF0000
#FF0000FF
x (object) – Value to check.
True if x is a hex color code.
True
x
bool
Examples
>>> is_hex_color("#FF0000") True >>> is_hex_color("#FF0000FF") True >>> is_hex_color("red") False