filesql = "INSERT INTO groupmsg(user,type,filename,msgtime) VALUES ('98coder', 'file','asw.png','"+datetime.datetime.now()+"')"
TypeError: can only concatenate str (not "datetime.datetime") to str
Python操作Mysql报错can only concatenate str (not “datetime.datetime“) to str
问题描述 filesql = "INSERT INTO groupmsg(user,type,filename,msgtime) VALUES ('98coder', 'file','asw.png','"+datetime.datetime.now()+"')"TypeError: can only concatenate str (not "datetime.datetime") to str解决方案问题是因为时间格式不正确,更换为dt=datetime.datetime.now()