1

The Chinese words in my views.py causes a failure, when I remove those words it will be correct. These Chinese words only present in the print sentence.

Is this a decode/encode problem? and how can I fix it?

When I vim the views.py in my server, it show the Chinese words incorrect. So I wonder maybe it is a decode/ecnode problem, am I right?

4

3 回答 3

2

添加# -*- coding: utf-8 -*-您的第一行,并通过添加前缀views.py将您的中文字符串标记为 unicode 。u

另见:

于 2013-07-29T19:13:03.133 回答
1

我已经解决了这个问题,当我使用("%sxxx" % var)语法时发生了这个问题,然后我将其更改为,("%s%s" % (var, u'xxx'))

有效,希望可以帮助其他人

于 2013-09-14T09:34:06.670 回答
1

使用如: ("%s%s" % (var, u'xxx'))

于 2014-08-28T15:50:43.413 回答