How can I convert special characters in a string back into escape sequences?

print(repr('a\tb'))

repr() gives you the “representation” of the string rather than the printing the string directly.

Leave a Comment