标签:bsp 读取文件 style 文件中 维数 new 代码 内容 long
1:将列表内的元素,根据位数合并成字典
lst = [1,2,4,8,16,32,64,128,256,512,1024,32769,65536,4294967296]
# 输出
{
1:[1,2,3,8],
2:[16,32,64],
3:[128,256,512],
4:[1024,],
5:[32769,65536],
6:[4294967296]
} 每次输出的数,位数加一
list = [1,2,4,8,16,32,64,128,256,512,1024,32769,65536,4294967296] dic = {} for i in list: if len(i) in dic: dic[len(str(i))].append(i) else: dic[len(str(i))] = [i]
2:将二维数组转换成一堆数组(转换前 lst = [[1,2,3],[4,5,6],[7,8,9]],转换后lst = [1,2,3,4,5,6,7,8,9])
list = [[1,2,3],[4,5,6],[7,8,9]] new_list = [] for i in list: new_list.extend(i) list = new_list
3:一个大小为100G的文件etl_long.txt,要读取文件中的内容,写出具体过程代码。
a=open(‘etl_log.txt‘,mode = ‘r‘, encoding = ‘utf-8‘) print(a.read()) with open(‘etl_log.txt‘, ‘r‘, encoding = ‘utf-8‘)as a: print(a.read())
标签:bsp 读取文件 style 文件中 维数 new 代码 内容 long
原文地址:https://www.cnblogs.com/ljy123/p/12797897.html