在做网络请求,传输的数据太多或者太少,都会很慢,请求太多数据可能卡死, 就请求指定数量的数据
def generator_five(parm, num):
"""
将列表切分成每5个来返回
:param parm:
:return:
"""
length = len(parm)
for i in range(0, length, num):
yield parm[i:i + num]
if __name__ == '__main__':
list_dict_data = [6925237600103,
6925237600127,
6921052700547,
800794000244,
800794000299,
800794000305,
6900956250952,
6900956250884,
6900956250884,
6900956250884,
800794000381,
800794000398,
800794000404,
800794000411,
874119008147,
874119008154,
800794001067,
800794001074,
800794001081,
800794001098,
800794001104,
800794001210,
800794002002,
800794002019,
800794002026,
800794002033,
800794002064,
800794002071,
800794002088,
800794002095,
800794002101,
]
for split_list_dict_data in generator_five(list_dict_data, 5):
print(split_list_dict_data)
标签:__,python,parm,list,列表,dict,拆分,data
From: https://www.cnblogs.com/qianxunman/p/17254266.html