TypeError: sequence item 1: expected str instance, int found

时间:2021-03-22 03:27:06

Error Msg

Traceback (most recent call last):
File "E:/code/adva_code/my_orm.py", line 108, in <module>
user.save()
File "E:/code/adva_code/my_orm.py", line 91, in save
sql = "insert {}({}) value({})".format(self._meta["db_table"], ",".join(fields), ",".join(values))
TypeError: sequence item 1: expected str instance, int found

问题:

  ",".join()接收的参数必须是str类型, 不接受其他类型

解决:

  修改join()参数为列表, 列表中全部为str类型: ","join(["1", "2", "3"...])