from email._header_value_parser import get_parameter x = 'r*="\'a\'\\"' print(repr(x)) print(repr(get_parameter(x)))