在下面的脚本中,a被全局设置为TC-01,b被全局设置为Passed,但是在执行时,我可以得到a的值,但是b的值我不能得到,所以请提供一些有价值的想法来获得b的值。

import HTML
import html2
from html2 import a,b

file = open('out.html', 'w')
# dictionary of test results, indexed by test id:
 test_results = {
a: 'b',-----> In this only a value is take , b is not taking the value.
#'Testcase-005': 'success'
#'Testcase-005': 'error',
    }

result_colors = {
'passed':      'lime',
'failed':      'red',
'error':        'yellow',
    }
t = HTML.Table(header_row=['Testcase - ID', 'Result'])
for test_id in sorted(test_results):
#create the colored cell:
print test_results
color = result_colors[test_results[test_id]]
colored_result = HTML.TableCell(test_results[test_id], bgcolor=color)
#append the row with two cells:
t.rows.append([test_id, colored_result])
htmlcode = str(t)
c=htmlcode
print htmlcode
file.write(c)

最佳答案

import HTML
import html2
from html2 import *
#print a
#print b
file = open('out.html', 'w')
table_data = [
['S.No',   'Testcase - ID',   'Result'],
['1',       a,         b],
['2',       c,         d],

]
htmlcode = HTML.table(table_data)
c=htmlcode
print htmlcode

文件写入(c)
在全球范围内打电话给a,b,c,d…我想它会起作用的

10-02 20:59