TypeError:无法连接“ str”和“ type”对象 [英] TypeError: cannot concatenate 'str' and 'type' objects

查看:67
本文介绍了TypeError:无法连接“ str”和“ type”对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在解决问题之前,我已经搜索了一个答案,但似乎找不到与我的情况有关的任何东西。

Before I get to my issue, I have searched around for an answer but cannot seem to find anything specific to my case.

好吧,基本上,我称呼我的脚本通过cmd并传入16个参数,并使用它们来设置一些我拥有的变量。我正在创建供我们公司使用的自定义html报告。这些变量仅用于动态设置我想要的html字符串中的值。我得到的错误是:

Ok, basically I call my script via cmd and pass in 16 args and use them to set some variables I have. I am creating a custom html report for our company use. These variables I just use to dynamically set the values I want where they are in html string. The error I get is:

>>> python -u "htmltest.py" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Traceback (most recent call last):
File "htmltest.py", line 162, in <module>
<TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-   left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT  VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C9+"""</FONT></TD>
TypeError: cannot concatenate 'str' and 'type' objects
>>> Exit Code: 1

我尝试删除某些变量,例如C9等,以查看其作用,但是

I have tried removing some of the variables like C9 etc to see what it does but it just errors on the one previous to that so I assume I have to make the variables the same as how I am doing my string?

代码是:

import sys
import datetime
#for each arg sent we can set each value starting at 2 since 1 is the actual name of  the script

CalFixUsed = sys.argv[1]
StationNumber = sys.argv[2]
Operator = sys.argv[3]
MMCalDueDate = sys.argv[4]
MMEquipID = sys.argv[5]
MBCalDueDate = sys.argv[6]
MeterBoxID = sys.argv[7]
C1 = sys.argv[8]
C2 = sys.argv[9]
C3 = sys.argv[10]
C4 = sys.argv[11]
C5 = sys.argv[12]
C6 = sys.argv[13]
C7 = sys.argv[14]
C8 = sys.argv[15]
C9 = sys.argv[16]

filename = "Daily Verification Test.html" 
today = datetime.date

html = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

<HTML>
<HEAD>

<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE></TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.3  (Win32)">
<META NAME="CREATED" CONTENT="0;0">
<META NAME="CHANGED" CONTENT="0;0">

<STYLE>
    <!-- 
    BODY,DIV,TABLE,THEAD,TBODY,TFOOT,TR,TH,TD,P { font-family:"Arial"; font-   size:x-small }
     -->
</STYLE>

 </HEAD>

<BODY TEXT="#000000">
<TABLE FRAME=VOID CELLSPACING=0 COLS=8 RULES=NONE BORDER=0>
<COLGROUP><COL WIDTH=43><COL WIDTH=65><COL WIDTH=57><COL WIDTH=65><COL WIDTH=81>   <COL WIDTH=65><COL WIDTH=65><COL WIDTH=65></COLGROUP>
<TBODY>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid   #000000; border-left: 1px solid #000000" COLSPAN=3 WIDTH=164 HEIGHT=20 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Calibration Fixture Used:</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 WIDTH=210 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+CalFixUsed+"""</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000" WIDTH=65 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Station #:</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-right: 1px solid #000000" WIDTH=65 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+StationNumber+"""</FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000" COLSPAN=2 HEIGHT=19 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Operator Name:</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=6 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+Operator+"""</FONT></TD>
        </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 HEIGHT=19 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Calibration Due Date</FONT></TD>
        <TD STYLE="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=2 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Equipment ID #</FONT></TD>
        </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 HEIGHT=20 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Multimeter</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+MMCalDueDate+"""</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=2 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+MMEquipID+"""</FONT></TD>
        </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000" HEIGHT=20 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Meter Box</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+MBCalDueDate+"""</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=2 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+MeterBoxID+"""</FONT></TD>
        </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Date:</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=2 ALIGN=CENTER VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">"""+today+"""</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=5 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-left: 1px solid #000000" HEIGHT=19 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=4 HEIGHT=19 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Contact Resistance Reading</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Comments:</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="1" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">1</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C1+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="2" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">2</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C2+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="3" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">3</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C3+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="4" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">4</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C4+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="5" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">5</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C5+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="6" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">6</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C6+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="7" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">7</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C7+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="8" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">8</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C8+"""</FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
        <TD STYLE="border-bottom: 1px solid #000000; border-right: 1px solid #000000" ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"><BR></FONT></TD>
    </TR>
    <TR>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" HEIGHT=19 ALIGN=CENTER VALIGN=BOTTOM SDVAL="9" SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">9</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+C9+"""</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=2 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000">Verification Initials:</FONT></TD>
        <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=2 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;1033;General"><FONT FACE="Calibri" COLOR="#000000"> <BR></FONT></TD>
        </TR>
</TBODY>
</TABLE>
</BODY>

</HTML>
"""
# Create a file object:
# in "write" mode

FILE = open(filename,"w")
# Write all the lines at once:
FILE.write(html)
FILE.close()

有人可以指出正确的方向来解决此问题吗?

Can someone point me in the right direction to fix this?

谢谢。

推荐答案

通常,当您尝试添加字符串和非字符串类型时会看到此错误。找出在该行中的哪个位置可以容纳非字符串对象的变量,然后将其放置在

Typically you see this error when you try to add a string and a non-string type. Find out where in that line you have a variable that could hold a non-string object, and place the "str()" around it. This will convert it to a string and concatenate them for you (if it's something simple, such as a number).

如果它是a,则将其转换为字符串并将其连接起来(如果它很简单,例如数字)。

If it's a class, you may need to dig deeper to get the string representation of it.

因此,例如,将第163行更改为:

So for example, change line 163 to:

    <TD STYLE="border-top: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000" COLSPAN=3 ALIGN=LEFT VALIGN=BOTTOM SDNUM="1033;0;0.000000"><FONT FACE="Calibri" COLOR="#000000">"""+str(C9)+"""</FONT></TD>

对您所有的 Cx行也要执行此操作。

You may need to do this for all of your "Cx" lines too.

这篇关于TypeError:无法连接“ str”和“ type”对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆