转换django Charfield“\t”到标签 [英] Convert django Charfield "\t" to tab

查看:84
本文介绍了转换django Charfield“\t”到标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有Charfield的django模型,它包含unicode转义的字符串 \\
最简单的方法是将其转换为真实的标签(如 str(\t))?

解决方案

找到答案:

 \\ t.decode(string_escape))


的mentaljetsam.wordpress.com/2007/04/13/unescape-a-python-escaped-string/rel =nofollow>这里

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

这篇关于转换django Charfield“\t”到标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆