【发布时间】:2016-04-11 08:39:48
【问题描述】:
我有:
surfaceList = [(21, 22, 2, 4, 24), (27, 28, 7, 4, 30)]
我想要:
The vertex are 21 22 2 4 24
The vertex are 27 28 7 4 30
我用过
totalSurface = len(surfaceList)
print " total surface = %d " % (totalSurface)
for surfaceGenNew in range(totalSurface):
print " The vertex are " surfaceList[surfaceGenNew]
错误是:
print " The vertex are %s" surfaceInformationVertexList[surfaceGenNew]
^
Error: invalid syntax
我也用过
foo = [(21, 22, 2, 4, 24), (27, 28, 7, 4, 30)]
print " \n The vertex are ".join(foo)
错误是
TypeError: sequence item 0: expected string, tuple found
我可以使用困难的方法来查找单个列表的长度,然后对每个列表项使用 if 条件,然后打印相同的内容,但我相信会有聪明的方法来做到这一点。
有什么建议吗?
【问题讨论】:
标签: python linux list delimiter