fork download
  1. import ast
  2.  
  3. def escape_decode(string) -> bytes:
  4. string = string.replace("'", r"\x27")
  5. return ast.literal_eval(f"b'{string}'")
  6.  
  7.  
  8. s = r"\xe9\x88\xb4\xe6\x9c\xa8"
  9. print(escape_decode(s).decode("utf-8"))
  10.  
Success #stdin #stdout 0.04s 9948KB
stdin
Standard input is empty
stdout
鈴木