【发布时间】:2017-02-07 13:06:12
【问题描述】:
我正在尝试从数据库创建具有 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'
【问题讨论】:
标签: python file api flask themoviedb-api