# inside class HoleScore
@staticmethod
def make_table(list_of_holes):
"""list_of_holes is a list of HoleScore objects"""
print("Some | headers | here")
for hole in list_of_holes:
fields = [hole.hole_number,
hole.par,
hole.handicap,
hole.target_score]
print("|".join(fields)) # use some string formatting here?
建立一个类。你知道吗
然后您可以添加一些dunder方法来帮助解决问题,或者(更好)设计一个函数来从一堆
HoleScore
对象构建一个表。比如:相关问题 更多 >
编程相关推荐