在Python中将列表转换为表格
我该如何把 students = [("Abe", 200), ("Lindsay", 180), ("Rachel" , 215)]
变成:
Abe 200
Lindsay 180
Rachel 215
这个方法应该适用于任何大小的列表。
1 个回答
2
在编程中,有时候我们会遇到一些问题,比如代码运行不正常或者出现错误。这个时候,我们可以去一些技术论坛,比如StackOverflow,去寻找解决办法或者向其他人请教。
在这些论坛上,很多人会分享他们的经验和解决方案。你可以看到其他人提问,然后有人会给出建议或者代码示例,帮助他们解决问题。
如果你在学习编程,记得多去这些地方看看,学习别人的问题和解决方法,这样可以帮助你更快地掌握编程技巧。
students = [("Abe", 200), ("Lindsay", 180), ("Rachel" , 215)]
for student in students:
print(*student, sep='\t') # python 3
for student in students:
print '\t'.join(str(i) for i in student) # python 2