开发者

django: how to get a substring?

I was modifying satchmo(a python online store project), but I found that I can't use [0, 5] to get the substring in the model. And I found the type is class 'django.utils.safestring.SafeUnicode' in django string processing.

Does开发者_StackOverflow class 'django.utils.safestring.SafeUnicode' support [0, 5] to get the substring as in python?


Slice it. http://docs.python.org/tutorial/introduction.html

>>> 'foobar'[0:5]
[Out] 'fooba'

Update: sure, why not?

>>> django.utils.safestring.SafeUnicode('foobar')[0:5]
[Out] 'fooba'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜