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")
)?
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'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.