【发布时间】:2020-11-21 04:54:08
【问题描述】:
我不确定循环出了什么问题,因为它说 [TypeError: can only concatenate str (not "int") to str] 特别是在这一行 -> msg.body = "Hi.. " + roll_id[i] + " is present for the lecture of " + "Prof. " +str(teacher_name.split('.',1)[0]) + ", which is held on " + excel_date + "@" + time + "hrs" 。有什么想法吗?
for i in range(len(roll_id)):
cursor.execute("SELECT student_email,parent_email from student_login where binary roll_id=%s",[roll_id[i]])
email = list(cursor.fetchone())
print(type(email[1]))
print(email[0])
print(email[1])
msg = Message('Auto Generated',recipients= [email[0],email[1]])
msg.body = "Hi.. " + roll_id[i] + " is present for the lecture of " + "Prof. " +str(teacher_name.split('.',1)[0]) + ", which is held on " + excel_date + "@" + time + "hrs"
msg.html = "Hi.. " + roll_id[i] + " is present for the lecture of " + "Prof. " +str(teacher_name.split('.',1)[0])+ ", which is held on " + excel_date + "@" + time + "hrs"
mail.send(msg)
return "<h1>mail sent<h1>"
【问题讨论】:
-
请完成您的问题以便理解。