Pythonic方法返回来自类的一串列表

时间:2015-12-22 18:11:58

标签: python string list python-2.7 class

B包含类型类B的列表,其中包含打印函数。我试图返回GetList()中所有打印元素的字符串,用新行分隔。什么是方法class A(): # ..... def GetList(self): temp = "" for item in self.ListOfTypeClassB: temp += item.Print() + "\n" return temp 的Pythonic“单行”方式?

{{1}}

我可以将新行添加到print方法中,如果它更清晰。

0 个答案:

没有答案