我收到缩进错误。任何人都可以帮助我修复它并获得def POST(self):
form = web.input(name="a", newname="s", number="d")
conn = MySQLdb.connect(host= "localhost", user="root", passwd="", db="testdb")
x = conn.cursor()
x.execute("SELECT * FROM details WHERE name = '%s'" % (form.name))
conn.commit()
items = x.fetchall()
for row in items:
print row[0], row[1],row[2]
print("<table border='1'>")
print("<tr>")
print("<th>name</th>")
print("<th>address</th>")
print("<th>number</th>")
print("</tr>")
print("<tr>")
print("<td>{0}</td>".format(row[0]))
print("<td>{1}</td>".format(row[1]))
print("<td>{2}</td>".format(row[2]))
print("</tr>")
print("</table>")
conn.rollback()
conn.close()
#return render.index(items)
if __name__ == "__main__":
app.run()
这是我的代码
print("</tr>")
print("</table>")
我在这些行中收到错误
select CountryCode, Language, floor(percentage) as speakers
from countrylanguage c
where percentage = (select max(percentage) from countrylanguage c2 where c2.countrycode = c.countrycode group by c2.countrycode)
答案 0 :(得分:1)
这是一个非常基本的错误。如果您使用的是sublime text.Please选择所有行。 在每行def POST的开头,将有两种模式。 一个是'_____'和'.......'。整个模式应该是相似的 'def POST(self):' 请确保删除此错误。
复制并粘贴此代码:
def POST(self):
form = web.input(name="a", newname="s", number="d")
conn = MySQLdb.connect(host= "localhost", user="root", passwd="", db="testdb")
x = conn.cursor()
x.execute("SELECT * FROM details WHERE name = '%s'" % (form.name))
conn.commit()
items = x.fetchall()
for row in items:
print row[0], row[1],row[2]
print("<table border='1'>")
print("<tr>")
print("<th>name</th>")
print("<th>address</th>")
print("<th>number</th>")
print("<tr>")
print("<td>{0}</td>".format(row[0]))
print("<td>{1}</td>".format(row[1]))
print("<td>{2}</td>".format(row[2]))
print("</tr>")
print("</table>")
conn.rollback()
conn.close()
#return render.index(items)
if __name__ == "__main__":
app.run()
感谢。