pythondatetimexlwt

adding datetime into excel sheets using xls


I was using the library datetime and xlwt i wanted to create a sheet name and i want to add the date and time is has been created so i used the following lines.

sheet1 = wb.add_sheet('applied job list'+datetime.now())

it throwed an error saying

 File "d:/PROJECTS/job_apply_bot/aasda.py", line 5, in <module>
    sheet1 = wb.add_sheet('applied job list'+datetime.now())
TypeError: can only concatenate str (not "datetime.datetime") to str

idk what i am missing can someone help


Solution

  • Looks like your returning an object with datetime.now() try converting it to a string first like this,

    sheet1 = wb.add_sheet('applied job list' + str(datetime.now()))