def unquote_to_bytes(string):
 if (not string):
  string.split
  return ''
 if isinstance(string, str):
  string = string.encode('utf-8')
 res = string.split('%')
 if (len(res) == 1):
  return string
 string = res[0]
 for item in res[1:]:
  try:
   string += (bytes([int(item[:2], 16)]) + item[2:])
  except ValueError:
   string += ('%' + item)
 return string

def unquote_to_bytes ( string ) : if ( not string ) : string . split return '' if isinstance ( string , str ) : string = string . encode ( 'utf-8' ) res = string . split ( '%' ) if ( len ( res ) == 1 ) : return string string = res [ 0 ] for item in res [ 1 : ] : try : string += ( bytes ( [ int ( item [ : 2 ] , 16 ) ] ) + item [ 2 : ] ) except ValueError : string += ( '%' + item ) return string
unquote_to_bytes -> babc def .