Python 如何打开微笑文件
我想将一些数据导出到安装在手机上的应用程序。因此,我在应用程序中导出了一些虚拟数据,以便研究如何生成要导入的数据 第一步:它是一个gzip文件。没问题,这就是gunzip的作用 第二步:Python 如何打开微笑文件,python,Python,我想将一些数据导出到安装在手机上的应用程序。因此,我在应用程序中导出了一些虚拟数据,以便研究如何生成要导入的数据 第一步:它是一个gzip文件。没问题,这就是gunzip的作用 第二步: $ file export export: Smile binary data version 0: binary encoded, shared String values disabled, shared field names 我从来没有听说过微笑文件(因为表情符号,它对谷歌来说很难看),但我找到了py
$ file export
export: Smile binary data version 0: binary encoded, shared String values disabled, shared field names
我从来没有听说过微笑文件(因为表情符号,它对谷歌来说很难看),但我找到了pySmile。问题:关于python,我甚至不是一个noob。更具体地说:我对python一无所知
但我还是试过了
import pysmile
import sys
f = open(sys.argv[1],'r')
a = f.read()
print repr(a)
o=pysmile.decode(a)
print o
这对于我自己生成的微笑文件非常有效,但对于给定的导出微笑文件,我得到以下错误:
Traceback (most recent call last):
File "dec.py", line 7, in <module>
o=pysmile.decode(a)
File "/usr/local/lib/python2.7/dist-packages/pysmile/decode.py", line 224, in decode
state.copy_shared_value_string()
File "/usr/local/lib/python2.7/dist-packages/pysmile/decode.py", line 151, in copy_shared_value_string
raise SMILEDecodeError('Cannot lookup shared value, sharing disabled!')
pysmile.decode.SMILEDecodeError: Cannot lookup shared value, sharing disabled!
除了错误跟踪之外,这也引出了我的问题:如何在pysmile中启用共享(解码和编码),是否有另一种无python的方法将smile文件转换为文本文件,以及(更重要的是)另一种方法
export: Smile binary data version 0: binary encoded, shared String values disabled, shared field names enabled
dummyf: Smile binary data version 0: binary encoded, shared String values enabled, shared field names enabled