我有一个list(包含字段名称)和list1(包含字段的各个值)(len(list)= len(list1)。问题是如果用户要在给定时更改列表中的字段名称,如何我显示吗?
我需要根据用户要求显示报告。例如 list = [“ sno”,“ time”,“ param”]而不是六个字段(在代码中给出),如何进行更改。如果未更改,则会以不合逻辑的形式显示html表
first.py
def resultstablesheadings(self,):
list = ["S.No", "TimeStamp", "Parameters", "ExpectedValue", "Status", "Comments"]
try:
self.htmlapp.write("<tr>")
for listValue in list:
if listValue=="ExpectedValue":
self.ExpectedValue=list.index("ExpectedValue")
if listValue=="Status":
self.status=list.index("Status")
if listValue=="Comments":
self.Comments=list.index("Comments")
self.htmlapp.write("<th>"+listValue+"</th>")
def resultstableupdate(self,list):
try:
list_len = len(list)
self.htmlapp.write("<tr>")
def slno_count(init=[0]):
init[0] += 1
return init[0]
list[0] = slno_count()
list[1] = datetime.datetime.now()
for listvalue in range(list_len-1):#0-5
if(listvalue==self.ExpectedValue):
self.DisplayImage(list[self.ExpectedValue])
continue
if(listvalue==self.status):
result_status = list[listvalue]
if (result_status==0):
self.htmlapp.write("<th >Pass</th>")
if (result_status==1):
self.fails_count=self.fails_count+1
self.htmlapp.write("<th>Fail</th>")
else:
result_status=list[listvalue]
self.htmlapp.write("<th>"+str(result_status)+"</th>")
for comment in range(list_len):
if(comment==self.Comments):
self.DisplayImage(list[self.Comments])
second.py
list1=["1","12:23:34","as","Hydrangeas.jpg",0,"Hydrangeas.jpg"]
resultstablesheadings()
resultstableupdate(list1)
预期: sno时间戳期望值状态注释 1 12:23:34 x.jpg通过y.jpg 实际 x.jpg通过y.jpg (仍然丢失,反之亦然)