如何编辑Evernote的ENML文件,尤其是在<en-media>标签中添加/修改width和height标签

问题描述

我想在我的所有Evernote笔记的媒体标签添加或编辑高度和宽度值。 想法是通过使图像在呈现便笺时显示为较小的图像,从而使便笺更具可读性,但要使图像保持原始大小,即粘贴到便笺时的原始大小。

<en-media type="image/jpg" hash="a2a50c9d6aab3f1f19c9d001f771d942" height="200" width="200" />

是否有一个python库,或者是最好的方法来编辑使用noteStore.getNote获得的note.content,然后大概可以使用noteStore.updateNote更新已编辑的注释。

谢谢!

解决方法

下方

import xml.etree.ElementTree as ET

en_xml = '''<doc><en-media type="image/jpg" hash="a2a50c9d6aab3f1f19c9d001f771d942" height="200" width="200" /></doc>'''

new_height = '300'
new_width = '300'

root = ET.fromstring(en_xml)

media = root.find('.//en-media')
media.attrib['height'] = new_height
media.attrib['width'] = new_width

ET.dump(root)

输出

<doc><en-media hash="a2a50c9d6aab3f1f19c9d001f771d942" height="300" type="image/jpg" width="300" /></doc>