黄舟2017-04-17 11:24:371楼
我忘记这代码是从哪儿来的了,大概是从这个改的吧:http://yongsun.me/2010/07/%E5%AF%BC%E5%85%A5sogou%E8%BE%93%E5%85%A5%E6%B3%95%E7%9A%84%E7%BB%86%E8%83%9E%E8%AF%8D%E5%BA%93/
importer.py
#!/usr/bin/python2
import struct
import os, sys
def read_utf16_str (f, offset=-1, len=2):
if offset >= 0:
f.seek(offset)
str = f.read(len)
return str.decode('UTF-16LE')
def read_uint16 (f):
return struct.unpack ('
def get_word_from_sogou_cell_dict (fname):
f = open (fname, 'rb')
file_size = os.path.getsize (fname)
hz_offset = 0
mask = struct.unpack ('B', f.read(128)[4])[0]
if mask == 0x44:
hz_offset = 0x2628
elif mask == 0x45:
hz_offset = 0x26c4
else:
sys.exit(1)