在学习Python时,我找到了Evernote的Python脚本b64dec.py,用于将.ENEX文件中描述的注释转换回其本机格式。你知道吗
一开始我还不清楚它是怎么工作的。例如,我找不到“cat”命令。(github清单中的第27行)
# cat base64File | python b64dec.py myfile.ext
我最后得出结论,你援引它的时候:
<source ENEX file> | python b64dec.py <outputfile.desired_extension >
对吗?你知道吗
我尝试过将纯文本注释发送到.txt文件,将纯图像注释发送到.jpg文件。它们最终都是零长度的文件。你知道吗
我是否正确调用此脚本。我是否正确理解其目的(将带有图像的音符转换回图像等)。你知道吗
#!/usr/bin/env python
# Copyright 2013 Evernote Corporation. All rights reserved.
import base64
import sys
# Copy the base64 string from the ENEX file and put it into a file
# Pipe base64-encoded data to STDIN
data = sys.stdin.read()
# Decode data
try:
imgraw = base64.b64decode(data)
except TypeError, te:
print 'TypeError: ', te
raise SystemExit
# Write it to the file passed as a param
with file(sys.argv[1], 'wb') as outfile:
outfile.write(imgraw)
## Usage:
## (Change myfile.ext to the desired filename and correct extension)
# cat base64File | python b64dec.py myfile.ext
## or, if you base64 data is in the pasteboard on a Mac:
# pbpaste | python b64dec.py myfile.ext
目前没有回答
相关问题 更多 >
编程相关推荐