html 파일을 작성하는 작은 스크립트를 작성하려고하는데이 파일에는 여러 제품에 대한 정보가있는 두 개의 행이 들어있는 테이블이 있어야합니다. 하지만 지금은이 테이블이 이전 입력 데이터에 따라 여러 번 반복 될 필요가 있기 때문에 html 코드가 포함 된 함수를 곱할 수는 있지만 실제로 작동하지 않는다고 생각했습니다. 사실,이전 입력에 따라 곱하기 함수
입력 ---> 얼마나 많은 테이블 : 3
을 약간의 도움이 나쁘지 않을 것 때문에 여기에서하고 m는 ...이 내가 원하는 것입니다 당신이 HTML 파일에 기록 중복 데이터가 필요한 경우 0
그래서 HTML 출력 파일이 여기에이
<-- TABLE 1 -->
<table>
<tr>
<td colspan="4" height="30"></td>
</tr>
<tr>
<td width="50" class="width6p"></td>
<td width="260" class="width44p"><a href="http://www.site/site/product/CODEPRODUCT_1" target="_blank"><img src="http://site/image/CODEPRODUCT_1" width="230" alt="DESCRIPTION_1" style="display:block" border="0" class="width90p"/></a></td>
<td width="30" class="width3p"></td>
<td width="260" class="width44p"><a href="http://www.site/site/product/CODEPRODUCT_2" target="_blank"><img src="http://site/image/CODEPRODUCT_2" width="230" alt="DESCRIPTION_2" style="display:block" border="0" class="width90p"/></a></td>
</tr>
<tr>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">DESCRIPTION_1</span ><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14"> DESCRIPTION_1</span><br/>
<span style="font-size:12px;" class="font12">SKU: CODEPRODUCT_-1</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">PRICE_1</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">DESCRIPTION_2</span><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14"> DESCRIPTION_2</span><br/>
<span style="font-size:12px;" class="font12">SKU: CODEPRODUCT_-2</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">PRICE_2</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
</tr>
<tr>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/site/product/CODEPRODUCT_1" target="_blank"><img src="http://www.site/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/site/product/CODEPRODUCT_2" target="_blank"><img src="http://www.site/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
</tr>
</table>
<-- TABLE 2 -->
<table>
<tr>
<td colspan="4" height="30"></td>
</tr>
<tr>
<td width="50" class="width6p"></td>
<td width="260" class="width44p"><a href="http://www.site/site/product/CODEPRODUCT_1" target="_blank"><img src="http://site/image/CODEPRODUCT_1" width="230" alt="DESCRIPTION_1" style="display:block" border="0" class="width90p"/></a></td>
<td width="30" class="width3p"></td>
<td width="260" class="width44p"><a href="http://www.site/site/product/CODEPRODUCT_2" target="_blank"><img src="http://site/image/CODEPRODUCT_2" width="230" alt="DESCRIPTION_2" style="display:block" border="0" class="width90p"/></a></td>
</tr>
<tr>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">DESCRIPTION_1</span ><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14"> DESCRIPTION_1</span><br/>
<span style="font-size:12px;" class="font12">SKU: CODEPRODUCT_-1</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">PRICE_1</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">DESCRIPTION_2</span><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14"> DESCRIPTION_2</span><br/>
<span style="font-size:12px;" class="font12">SKU: CODEPRODUCT_-2</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">PRICE_2</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
</tr>
<tr>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/site/product/CODEPRODUCT_1" target="_blank"><img src="http://www.site/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/site/product/CODEPRODUCT_2" target="_blank"><img src="http://www.site/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
</tr>
</table>
<-- TABLE 3 -->
<table>
<tr>
<td colspan="4" height="30"></td>
</tr>
<tr>
<td width="50" class="width6p"></td>
<td width="260" class="width44p"><a href="http://www.site/site/product/CODEPRODUCT_1" target="_blank"><img src="http://site/image/CODEPRODUCT_1" width="230" alt="DESCRIPTION_1" style="display:block" border="0" class="width90p"/></a></td>
<td width="30" class="width3p"></td>
<td width="260" class="width44p"><a href="http://www.site/site/product/CODEPRODUCT_2" target="_blank"><img src="http://site/image/CODEPRODUCT_2" width="230" alt="DESCRIPTION_2" style="display:block" border="0" class="width90p"/></a></td>
</tr>
<tr>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">DESCRIPTION_1</span ><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14"> DESCRIPTION_1</span><br/>
<span style="font-size:12px;" class="font12">SKU: CODEPRODUCT_-1</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">PRICE_1</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">DESCRIPTION_2</span><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14"> DESCRIPTION_2</span><br/>
<span style="font-size:12px;" class="font12">SKU: CODEPRODUCT_-2</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">PRICE_2</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
</tr>
<tr>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/site/product/CODEPRODUCT_1" target="_blank"><img src="http://www.site/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/site/product/CODEPRODUCT_2" target="_blank"><img src="http://www.site/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
</tr>
</table>
처럼 보일 것이다 것은 내 파이썬 코드
import locale
import requests
import urlparse
import json
def html(sku_01,desc_01,sku_precio_1,sku_02,desc_02,sku_precio_2,bloque_prod):
f = open('mkt-output.html','w')
f.write(bloque_prod)
f.close()
if __name__ == '__main__':
sku_01 = raw_input('Ingrese SKU: ')
desc_01 = raw_input('Descripcion de SKU: ')
sku_precio_1 = raw_input('Precio de SKU: ')
sku_02 = raw_input('Ingrese SKU: ')
desc_02 = raw_input('Descripcion de SKU: ')
sku_precio_2 = raw_input('Precio de SKU: ')
bloque_prod = """<table>
<tr>
<td colspan="4" height="30"></td>
</tr>
<tr>
<td width="50" class="width6p"></td>
<td width="260" class="width44p"><a href="http://www.site/product/{}" target="_blank"><img src="http://site/images/{}" width="230" alt="{}" style="display:block" border="0" class="width90p"/></a></td>
<td width="30" class="width3p"></td>
<td width="260" class="width44p"><a href="http://www.site/product/{}" target="_blank"><img src="http://site/images/{}" width="230" alt="{}" style="display:block" border="0" class="width90p"/></a></td>
</tr>
<tr>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">{}</span ><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14">{} {}</span><br/>
<span style="font-size:12px;" class="font12">SKU: {}-{}</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">{}</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
<td></td>
<td class="font14" valign="top" style=" font-size: 16px; inline-height:0px; font-family:Helvetica, sans-serif; font-weight:lighter; color:#666666; line-height:130%; padding:10px 0px;">
<span style="font-weight: bold; color:#008EAA" class="font14">{}</span><br />
<span style="font-weight: bold; color:#008EAA; font-size:14px;" class="font14">{} {}</span><br/>
<span style="font-size:12px;" class="font12">SKU: {}-{}</span><br />
<span style="font-size:18px;" class="font14">$ </span>
<span style="font-size:24px; line-height:30px;" class="font20">{}</span>
<span style="font-size:12px; text-transform: uppercase;" class="font10"> C/U</span> <br>
</td>
</tr>
<tr>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/product/{}" target="_blank"><img src="http://www.site/templates/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
<td></td>
<td style="inline-height:0px;padding-top:4px;"><a href="http://www.site/product/{}" target="_blank"><img src="http://www.site/templates/images/loquiero_med.png" width="142" title="Ver producto" style="display:block" border="0" class="width115"/></a></td>
</tr>
</table>""".format(sku_01,
sku_01,
desc_01,
sku_02,
sku_02,
desc_02,
' '.join(desc_01.split()[0:3]),
' '.join(desc_01.split()[3:-1]),
desc_01.split()[-1],
sku_01[0:-1],
sku_01[-1],
sku_precio_1,
' '.join(desc_02.split()[0:3]),
' '.join(desc_02.split()[3:-1]),
desc_02.split()[-1],
sku_02[0:-1],
sku_02[-1],
sku_precio_2,
sku_01,
sku_02)
html(sku_01, desc_01, sku_precio_1, sku_02, desc_02, sku_precio_2, bloque_prod)
'format()'에 의해 반환 된 문자열에 요청 된 반복 횟수를 곱합니다. –