【发布时间】:2016-02-09 01:39:41
【问题描述】:
如何显示所有具有相同标题的笔记,并将其标题与内容一起显示。
你知道如何显示每条笔记的标题和内容吗? 如https://sandbox.evernote.com。
我有一些具有相同标题的笔记,并希望将这些笔记的所有列表与其他笔记一起显示。
What the right combination of lists and dicts or other structures ?
我收到错误:列表索引必须是整数,而不是 str。
nb = []
nb.append([])
for note in result_list.notes:
content = note_store.getNoteContent(auth_token,
note_store.getNote(note.guid,
True,False, False, False).guid)
nb[note.guid].append([note.title, html2text.html2text(BeautifulSoup(ENMLToHTML(content), "html.parser").prettify()) ])
return render_to_response('oauth/callback.html', {'notebooks': notebooks,
'result_list': result_list,
'nb': nb})
.
<ul>
{% for i,j,n in enumerate(nb) %}
<li><b>{{ nb[i][j][n] }}</b><br>{{ nb[i][j][n+1] }}</li>
{% endfor %}
</ul>
理想输出的样本:
-
2600 杂志:黑客季刊
任何对 Apple 产品的液体损坏都会使您的保修失效。
我已经有了以这种方式输出的工作代码,但是
目前:
每个标题只显示一个注释,
或
显示具有相同标题的所有笔记,并在内容旁边显示 guid(所有笔记都很好,但我需要在内容旁边输出标题)
p.s
又一次尝试:
title_contents = {}
for note in result_list.notes:
content = note_store.getNoteContent(auth_token,
note_store.getNote(note.guid,
True,False, False, False).guid)
title_contents[ note.guid ] = [ note.title, html2text.html2text(BeautifulSoup(ENMLToHTML(content), "html.parser").prettify()) ]
return render_to_response('oauth/callback.html', {'notebooks': notebooks,
'result_list': result_list,
'title_contents': title_contents})
Django 的 html:
<ul>
{% for content in title_contents.items %}
<li><b>{{ content }}</b><br>{{ content }}</li>
{% endfor %}
</ul>
当前输出:
('c41c95b1-d2c5-481d-9fa6-34342371aba3', ['hi', u'hello *\n\n'])
('c41c95b1-d2c5-481d-9fa6-34342371aba3', ['hi', u'hello *\n\n'])
我尝试通过 index 获取标题和内容,例如:
<ul>
{% for content in title_contents.items %}
<li><b>{{ content[0] }}</b><br>{{ content[1] }}</li>
{% endfor %}
</ul>
但得到另一个错误:
TemplateSyntaxError at /callback/
Could not parse the remainder: '[0]' from 'content[0]'
2016 年 2 月 10 日:
我开始使用 Node Js 编写这个网络应用程序,
并且所有的东西都在控制台中正常工作(当然,使用令牌 oauth,只显示文本,从文件中导入注释(简单解析),显示选择的注释等)。
我需要具有简单 Web 界面的类似应用程序,最好使用 Node Js Express。
在使用 Node Js Express 时,我开始用 Python (Django) 编写类似的东西。
我不知道哪个框架(Express 或 Django)更容易应对所有挑战。
这就是我从事这两个项目的原因。
EDAMTest.js 非常简单明了,但只适用于控制台环境。
在这种情况下,Node Js Express 对我来说比 Django 好得多,但我认为使用 Django 会更容易实现。
【问题讨论】:
-
请不要修改您的问题来添加另一个问题。
标签: python django data-structures evernote