def save_code(code, filename='code.xlsx'):
    'code本地输出\n    1、输出为json格式，根据文件名自动识别\n    2、输出为Excel格式\n    see also read_code\n    '
    save_type = os.path.splitext(filename)[1][1:]
    if (save_type == 'json'):
        code = pd.DataFrame(code)
        code.to_json(filename, force_ascii=False)
        return
    tmp = pd.DataFrame(columns=['name', 'value1', 'value2'])
    i = 0
    if all([('Q' in c[0]) for c in code.keys()]):
        key_qlist = sorted(code, key=(lambda c: int(re.findall('\\d+', c)[0])))
    else:
        key_qlist = code.keys()
    for key in key_qlist:
        code0 = code[key]
        tmp.loc[i] = ['key', key, '']
        i += 1
        for key0 in code0:
            tmp2 = code0[key0]
            if ((type(tmp2) == list) and tmp2):
                tmp.loc[i] = [key0, tmp2[0], '']
                i += 1
                for ll in tmp2[1:]:
                    tmp.loc[i] = ['', ll, '']
                    i += 1
            elif ((type(tmp2) == dict) and tmp2):
                try:
                    tmp2_key = sorted(tmp2, key=(lambda c: float(re.findall('[\\d\\.]+', ('%s' % c))[(- 1)])))
                except:
                    tmp2_key = list(tmp2.keys())
                j = 0
                for key1 in tmp2_key:
                    if (j == 0):
                        tmp.loc[i] = [key0, key1, tmp2[key1]]
                    else:
                        tmp.loc[i] = ['', key1, tmp2[key1]]
                    i += 1
                    j += 1
            elif tmp2:
                tmp.loc[i] = [key0, tmp2, '']
                i += 1
    if (sys.version > '3'):
        tmp.to_excel(filename, index=False, header=False)
    else:
        tmp.to_csv(filename, index=False, header=False, encoding='utf-8')
code本地输出
1、输出为json格式，根据文件名自动识别
2、输出为Excel格式
see also read_code
def save_code(code, filename='code.xlsx'):
    'code本地输出\n    1、输出为json格式，根据文件名自动识别\n    2、输出为Excel格式\n    see also read_code\n    '
    save_type = os.path.splitext(filename)[1][1:]
    if (save_type == 'json'):
        code = pd.DataFrame(code)
        code.to_json(filename, force_ascii=False)
        return
    tmp = pd.DataFrame(columns=['name', 'value1', 'value2'])
    i = 0
    if all([('Q' in c[0]) for c in code.keys()]):
        key_qlist = sorted(code, key=(lambda c: int(re.findall('\\d+', c)[0])))
    else:
        key_qlist = code.keys()
    for key in key_qlist:
        code0 = code[key]
        tmp.loc[i] = ['key', key, ]
        i += 1
        for key0 in code0:
            tmp2 = code0[key0]
            if ((type(tmp2) == list) and tmp2):
                tmp.loc[i] = [key0, tmp2[0], ]
                i += 1
                for ll in tmp2[1:]:
                    tmp.loc[i] = [, ll, ]
                    i += 1
            elif ((type(tmp2) == dict) and tmp2):
                try:
                    tmp2_key = sorted(tmp2, key=(lambda c: float(re.findall('[\\d\\.]+', ('%s' % c))[(- 1)])))
                except:
                    tmp2_key = list(tmp2.keys())
                j = 0
                for key1 in tmp2_key:
                    if (j == 0):
                        tmp.loc[i] = [key0, key1, tmp2[key1]]
                    else:
                        tmp.loc[i] = [, key1, tmp2[key1]]
                    i += 1
                    j += 1
            elif tmp2:
                tmp.loc[i] = [key0, tmp2, ]
                i += 1
    if (sys.version > '3'):
        tmp.to_excel(filename, index=False, header=False)
    else:
        tmp.to_csv(filename, index=False, header=False, encoding='utf-8')