bug in “django-admin.py makemessages” or xgettext call? -> “warning: unterminated string”

落花浮王杯 提交于 2019-12-02 10:08:52

I can think of two possibilities: you might have an extra space after your backslash at the end of the line; or you might be somehow ending up with the wrong line-ending characters in your source (e.g. Windows-style when your Python is expecting Unix-style, thus disabling the backslashes).

Either way, I would take advantage of C-style automatic string concatenation:

>>> string = ("some text "
...           "more text "
...           "and even more")
>>> string
'some text more text and even more'

Alternatively, if you don't mind newlines ending up in there, use multi-line strings:

>>> string = """some text
...             more text
...             and even more"""

IMO these look much nicer, and are much less fragile when refactoring.

Does this help?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!