解决这个简单问题的好方法是什么?
def __unicode__(self):
return unicode(self.typePlace + " " + self.name)str:+:'TipoLugar‘和’TypeError‘不支持的操作数类型
发布于 2012-07-30 05:57:17
使用字符串格式而不是组合,这既更有效,也将为您的元素字符串:
return u"%s %s" % (self.typePlace, self.name)发布于 2012-07-30 04:07:59
假设typePlace本身是一个具有自己的__str__()和/或__unicode__()函数的对象(如果它不是,并且它是一个自定义类,那么您应该添加这些方法)。因此,在使用之前,将typePlace转换为unicode字符串:
return unicode(unicode(self.typePlace) + " " + self.name)https://stackoverflow.com/questions/11712511
复制相似问题