我希望在我的笔记的note.content中添加一个包含用户文本输入的字符串。阅读后,我发现了如何添加资源,但我不希望资源成为附件,我希望它是实际的文本。
以下是一些代码:
title= self.textEditTitle.text()
body= self.textEditBody.text()
auth_token = "secret stuff!"
client = EvernoteClient(token=auth_token, sandbox=True)
note_store = client.get_note_store()
nBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
nBody += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
nBody += "<en-note>%s</en-note>" % body
note = Types.Note()
note.title = title
note.content= nBody
任何建议都会很棒,因为我刚刚开始使用这个api,一旦我弄明白,它看起来很有潜力!以下是我最常阅读的内容:http://dev.evernote.com/documentation/cloud/chapters/ENML.php
答案 0 :(得分:0)
找到答案。首先,我使用的是QString对象,而不是普通的字符串对象。我将QString作为一个字符串输出,并将内容分开,因此我自己连接了body变量。我还将字符串编码为xmlcharrefreplace,但我仍在阅读。不过,它有效。这是代码的剪辑:
body= str(self.textEditBody.text())
auth_token = "secret!"
client = EvernoteClient(token=auth_token, sandbox=True)
note_store = client.get_note_store()
nBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
nBody += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
nBody += "<en-note>"
nBody += body.encode('ascii', 'xmlcharrefreplace')
nBody += "</en-note>"