简体   繁体   中英

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") )?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM