Error code : ValueError: unsupported format character 'Y' (0x59) at index 89
错误语句:sql = "select id, role_id, username, nickname, sex, email, tel, intro, date_format(createtime,'%Y-%m-%d %H:%I:%s') as createtime from user limit %s, %s" % (pagenum, pagesize)
Reason : The " % " in the date_format(createtime,'%Y-%m-%d %H:%I:%s') in the sql statement conflicts with the python variable parameter writing.
One of the solutions : Separate the variable parameter " %s " in the sql statement from the sentence and write it in splicing,
如"select * from user where username = " + "'%s'" % username
改正语句:sql = "select id, role_id, username, nickname, sex, email, tel, intro, date_format(createtime,'%Y-%m-%d %H:%I:%s') as createtime from user limit " + "%s," % pagenum + "%s" % pagesize