Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: cannot concatenate 'str' and 'type' objects

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

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

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?

The code is:

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?

Thanks.

like image 480
Tom Avatar asked Apr 16 '12 18:04

Tom


2 Answers

today = datetime.date

sets today to the type datetime.date. Most likely, you want to set it to an object of type datetime.date, like this:

today = datetime.date(2012, 4, 16)
# or, to always get the current day
today = datetime.datetime.now().date()

You'll also need to generate a string from that date object. You can do that with str:

    """...""" + str(today) + """..."""

If you want another representation, have a look at datetime.date.isoformat and datetime.date.strftime.

like image 152
phihag Avatar answered Oct 16 '22 10:10

phihag


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).

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

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>

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

like image 3
lightningmanic Avatar answered Oct 16 '22 10:10

lightningmanic