zoukankan      html  css  js  c++  java
  • python强大的数据类型转换

    #  原始的二维表数据集
    jsonObj=[]
    # 添加模拟的数据
    for i in range(1001,1004):
        for j in range(1,34):
            jsonObj.append({"bureau_id":i,'bureau_name':''+str(i)+"",'person_id':10000+j})
    
    # 结构化的数据集
    personDict={}
    for obj in jsonObj:
        if 'bureau_'+str(obj['bureau_id']) not in personDict:
            personDict['bureau_'+str(obj['bureau_id'])]={'bureau_name':obj['bureau_name']}
    
        if 'personIds' not in  personDict['bureau_' + str(obj['bureau_id'])]:
            personDict['bureau_' + str(obj['bureau_id'])]['personIds']=[]
        personDict['bureau_' + str(obj['bureau_id'])]['personIds'].append(obj['person_id'])
    
    BatchSize=10
    
    for c in personDict:
        # 群组id
        group_id=c
        # 群组名
        group_name=personDict[c]['bureau_name']
        # 有哪些人员
        count=1
        while len(personDict[c]['personIds'])>BatchSize:
            print(''+str(count)+'轮提交的数据:'+str(personDict[c]['personIds'][:BatchSize]))
            del personDict[c]['personIds'][:BatchSize]
            count+=1
    
        print('最后一轮提交的数据:' + str(personDict[c]['personIds']))
        print('====================================')
  • 相关阅读:
    二叉树的遍历
    98验证二叉搜索树
    104二叉树的最大深度
    101对称二叉树
    100相同的树
    递归算法
    52N皇后II
    51N皇后
    90子集II
    526优美的排列
  • 原文地址:https://www.cnblogs.com/littlehb/p/8921884.html
Copyright © 2011-2022 走看看