如题,我试着使用 Template 无法实现
htmlstr="""
$("input[type=text]").prop("readonly",true);
$('#Index_000003_Spec_0001').val('$value1');$('#Index_000003_Spec_0002').val('$value2');$('#Index_000003_Spec_0003').val('$value3');$('#Index_000003_Spec_0004').val('$value4');$('#Index_000004_Spec_0001').val('$value5');$('#Index_000004_Spec_0002').val('$value6');$('#Index_000004_Spec_0003').val('$value7');$('#Index_000004_Spec_0004').val('$value8');
//
$('#Index_000014_Spec_0002').val('$value201');$('#Index_000014_Spec_0003').val('$value202');$('#Index_000014_Spec_0004').val('$value203');
"""
value1,value2,value3,value4,value5,value6,value7,value8=63,"ret",67,67,356,4,445,26
from string import Template
htmlstr.substitute(value1,value2,value3,value4,value5,value6,value7,value8)
print(htmlstr)
htmlfile = open(("outfile.html"), "w")
htmlfile.write(htmlstr)
htmlfile.close()
报这个错
AttributeError: 'str' object has no attribute 'substitute':
使用直接赋值也不对,200 多个值一个个赋值实在有些繁琐
htmlstr.substitute(value1=211,value2=421)