我有一个有几个属性的类。我只希望每个属性的值分别在一行上。
我尝试使用map但它指向列表中每个类(<task_Backlog_Puller.Case object at 0x7ff2018f0240>
)的实例,我需要获取每个类属性的值。我无法从第三方导入库。
class Case:
def __init__(self, case_number, owner, title, status, priority, date_created):
self.case_number = case_number
self.owner = owner
self.title = title
self.status = status
self.priority = priority
self.date_created = date_created
def create_report_of_cases_older_than_30_days(total_number_of_all_cases, number_of_cases_older_than_30_days, cases_older_than_30_days):
report = "Total number of cases in team backlog is " + str(total_number_of_all_cases) + '\n'
report += "Total number of cases older than 30 days is " + str(number_of_cases_older_than_30_days) + '\n'
report += '\n'
report += '\n'.join(map(str, cases_older_than_30_days))
logger.info("Report -> {}".format(report))
return str(report)
2017-07-06 18:27:00,422 [ INFO] task_Backlog_Puller.116 --- Report -> Total number of cases in team backlog is 17
Total number of cases older than 30 days is 9
<task_Backlog_Puller.Case object at 0x7ff2018f0240>
<task_Backlog_Puller.Case object at 0x7ff202540a20>
<task_Backlog_Puller.Case object at 0x7ff1fe3b45f8>
<task_Backlog_Puller.Case object at 0x7ff20043ee80>
<task_Backlog_Puller.Case object at 0x7ff20043ee10>
<task_Backlog_Puller.Case object at 0x7ff2018d16a0>
<task_Backlog_Puller.Case object at 0x7ff2018d1cf8>
<task_Backlog_Puller.Case object at 0x7ff2018d1a58>
<task_Backlog_Puller.Case object at 0x7ff2018d1e80>
答案 0 :(得分:3)
为了控制如何将python类强制转换为字符串,可以在类定义中定义defaultConfig {
applicationId "type the new app Id here "
}
函数。
__str__