zoukankan      html  css  js  c++  java
  • python excel处理

    #!/usr/bin/python
    # data:2018/4/20
    # user:fei
    # -*- coding: utf-8 -*-
    import json
    import sys
    import time
    import openpyxl
    import json
    
    creat_data=time.strftime('%Y-%m-%d',time.localtime())
    i=1
    wb = openpyxl.Workbook()
    sheet = wb.active
    sheet.title = (creat_data + '-people')
    field = ['类型', '姓名', '用户名', '单位', '职务', '科室']
    for title in field:  # 写入表头
        sheet.cell(row=1, column=i, value=title)
        i += 1
    
    with open('C:/Users/fei/PycharmProjects/git_data/python_base/day10/json','r+',encoding='utf8') as f:
        load_dict = json.load(f)
        for line in load_dict:
            info=line['data']
            basic_info=info['basic']
            job_info=info['job']
            user_type=info['account_type']
            username=basic_info['real_name']
            user_id=basic_info['username']
            organization=job_info['organization']
            position=job_info['position'][0]
            department=job_info['department']
            all_info=[user_type,username,user_id,organization,position,department]
            # print(all_info)
            sheet.append(all_info)
        wb.save('test.xlsx')
    print('打印完成')
  • 相关阅读:
    拆分跨天的时间数据
    模板
    更换数据库服务器迁移步骤
    缺失索引
    flex布局解说和属性
    Vuejs中关于computed、methods、watch,mounted的区别
    皮囊
    回家
    江苏旅游计划
    重写原生alert,弹出层过一会就消失
  • 原文地址:https://www.cnblogs.com/tengfei520/p/9013861.html
Copyright © 2011-2022 走看看