假设它是给定的以下结构:
from django.utils.translation import ugettext_lazy as _
# Constants for all available difficulty types.
SIMPLE = 1
MEDIUM = 2
DIFFICULT = 3
# Names for all available difficulty types.
DIFFICULTIES = (
(SIMPLE, _("simple")),
(MEDIUM, _("medium")),
(DIFFICULT, _("difficult")),
)
如果给定一个常量,你如何获得字符串值?
循环很容易编程,但是有没有一个更短的类似 python 的方式和一个表达式?
表达方式
困难[简单][1]
返回字符串“中”。有什么明显的错误。