###前提・実現したいこと
https://github.com/appdamacy/Grape
上記ソースコードで
return template('index', row=row)となっている箇所を
return template('index', row)とした場合にエラーになる理由を知りたいです。
row=rowとすることでどういった処理が行われているのでしょうか。
###発生している問題・エラーメッセージ
ValueError('dictionary update sequence element #0 has length 4; 2 is required',)
###該当のソースコード
import sqlite3 import feedparser from bottle import route, run, template, static_file, debug debug(True) @route('/static/<filepath:path>') def static(filepath): return static_file(filepath, root="./static") @route('/hello') def hello(): con = sqlite3.connect('grape.db') c = con.cursor() c.execute("create table if not exists item (title, link, summary, updated)") url = [ "https://lineblog.me/sakuraihinako/atom.xml", "https://lineblog.me/masuwakatsubasa/atom.xml", "https://lineblog.me/funayamakumiko/atom.xml" ] feed = [] for rss in url: feed.extend(feedparser.parse(rss).entries) for item in feed: title = item.title link = item.link summary = item.summary updated = item.updated c.execute('INSERT INTO item VALUES (?, ?, ?, ?)', (title, link, summary, updated)) c.execute(u"select * from item order by updated desc") row = [] for item in c: row.append({ "title": item[0], "link": item[1], "summary": item[2], "updated": item[3] }) c.close() return template('index', row) run(host='localhost', port=8080) ``` ###試したこと
pythonのコードはインデントがないと意味が取れないので、前後行を ``` で括って正しく表示されるようにした方がいいですよ。

回答3件
あなたの回答
tips
プレビュー