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('====================================')
python强大的数据类型转换的更多相关文章
- 『无为则无心』Python基础 — 11、Python中的数据类型转换
目录 1.为什么要进行数据类型转换 2.数据类型转换本质 3.数据类型转换用到的函数 4.常用数据类型转换的函数 (1)int()函数 (2)float()函数 (3)str()函数 (4)bool( ...
- C/C++扩展Python的时候数据类型转换的对应:
- Python常用的数据类型转换
在实际开发中.经常要根据需求来转变一些变量的类型. 需要用到以下函数:
- python基础之数据类型转换
方法转换:str -->list str.split() list -->str ''.join(list)强制转换:str -->list list(str) str --> ...
- python 全栈开发,Day50(Javascript简介,第一个JavaScript代码,数据类型,运算符,数据类型转换,流程控制,百度换肤,显示隐藏)
一.Javascript简介 Web前端有三层: HTML:从语义的角度,描述页面结构 CSS:从审美的角度,描述样式(美化页面) JavaScript:从交互的角度,描述行为(提升用户体验) Jav ...
- Python基础学习笔记(九)常用数据类型转换函数
参考资料: 1. <Python基础教程> 2. http://www.runoob.com/python/python-variable-types.html 3. http://www ...
- 简谈-Python的输入、输出、运算符、数据类型转换
输出: 格式化输出: 看到了 % 这样的操作符,这就是Python中格式化输出. 换行输出: 在输出的时候,如果有 \n 那么,此时 \n 后的内容会在另外一行显示 输入: 在python2.7当中, ...
- Python基础之模块、数据类型及数据类型转换
一.模块 1.标准库 不需要安装,直接调入使用的模块. import sys模块: import sys print(sys.path) #打印环境变量绝对路径 print(sys.argv) #打印 ...
- Python数据类型转换函数
数据类型转换函数 函 数 作 用 int(x) 将 x 转换成整数类型 float(x) 将 x 转换成浮点数类型 complex(real[,imag]) 创建一个复数 str(x) 将 x 转换为 ...
随机推荐
- cxf 动态调用.
import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache ...
- We Need More Bosses CodeForces - 1000E(缩点 建图 求桥 求直径)
题意: 就是求桥最多的一条路 解析: 先求连通分量的个数 然后缩点建图 求直径即可 #include <bits/stdc++.h> #define mem(a, b) memset(a ...
- CodeForces - 707C
C. Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input standa ...
- bzoj2817[ZJOI2012]波浪
题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=2817 波浪 [问题描述] 阿米巴和小强是好朋友. 阿米巴和小强在大海旁边看海水的波涛.小 ...
- RK哈希(Rabin_Karp 哈希)
Rabin_Karp 哈希通过比较hash值是否相等来比较每个字符串是否相等有概率出错(很小)字符串x1,x2,x3……xk基底e;模数mo;hash=(xk*e^0+xk-1*e^1+......+ ...
- 【POJ2796】Feel Good 单调栈
题目大意:给定一个长度为 N 的序列,求任意区间 [ l , r ] 中最小的\(min\{v[i],i\in[l,r] \}*\Sigma_{i=l}^rv[i]\). 题解:这是一道具有标准单调栈 ...
- 1: mysql left join,right join,inner join用法分析
下面是例子分析表A记录如下: aID aNum 1 a20050111 2 a20050112 3 a20050113 4 ...
- ubuntu14的unity desktop显示异常
在多用户下,卸载compiz后某个单一用户出现菜单栏和任务栏图标消失的情况. 这时,需要在图形界面下重置compiz $dconf reset -f /org/compiz/ 重启unity $set ...
- Helm二:安装
目录 Helm安装 Helm client安装 Helm tiller安装 Chart仓库配置 私有chart仓库 chart仓库的组成 创建本地仓库 chart仓库基本管理 Helm安装 Helm ...
- redis支持的数据结构
redis数据库里面的每个键值对都是由对象组成的. 其中数据库键的值总是字符串对象. 数据库的值则可以是字符串对象(String),列表对象(list),哈希对象(Hash),集合对象(Set),有序 ...