Skip to content Skip to sidebar Skip to footer

Convert Django Charfield "\t" To Tab

I have a django model with a Charfield that contains the unicode escaped string '\\t'. What is the easiest way to convert this to a real tab (as in str('\t'))?

Solution 1:

Found the answer:

"\\t".decode("string_escape")

as described here in the comments

In Python3 syntax:

In [5]: b'\\t'.decode("unicode_escape")
Out[5]: '\t'

Post a Comment for "Convert Django Charfield "\t" To Tab"