我正在尝试从数据库创建带有 id 的文件并插入一些文本,但它仍然不想让我这样做。
self.a.execute(
"""INSERT INTO serial (serial.Name, Description, GenreID, CreationDate) VALUES (%s, %s, %s, %s)""",
(title, overview, genre, release_date))
self.a.execute("""SELECT id, serial.Name FROM serial WHERE Name=%s""", title)
title = str(self.a.fetchall()[0]['id'])
with open("templates/serials/" + title + '.html', 'w+') as o:
o.write("""
{% extends '../base.html' %}
{% block content %}
<p>%s</p>
{% endblock %}
""" % (title))
如果我%(title)
在写函数之后放置,它会返回unsupported operand type(s) for %: 'int' and 'str'