python中的“ _”是什么意思?
在阅读Django的源代码时,我发现一些语句:
class Field(object):
"""Base class for all field types"""
__metaclass__ = LegacyConnection
# Generic field type description, usually overriden by subclasses
def _description(self):
return _(u'Field of type: %(field_type)s') % {
'field_type': self.__class__.__name__
}
description = property(_description)
class AutoField(Field):
description = _("Integer")
我知道它将描述设置为’Integer’,但不了解语法:description = _("Integer")
。
有人可以帮忙吗?
-
请阅读国际化(i18n)
http://docs.djangoproject.com/en/dev/topics/i18n/
的
_
是该字符串翻译成另一种语言功能的常用名称。http://docs.djangoproject.com/en/dev/topics/i18n/translation/#standard-
translation