我正在处理非常大的数据量。我的代码中有一个计算需要花费很多时间。代码如下:
chester_output_connections = ['0', '5', '0', '1', '0', '2', '0', '3', '0', '4', '1', '9', '1', '2', '1', '6', '1', '8', '2', '9', '2', '3', '2', '8', '3', '9', '3', '7', '3', '8']
dic = {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, '2fit': 7}
for index,item in enumerate(chester_output_connections):
for k,v in dic.items():
if str(v)==str(item):
chester_output_connections[index]=str(k)
请为更好的运行时间提出建议。你知道吗
如果不将比较转换为字符串,可能会有帮助
可能(因为项已经是字符串)
可能会加速一点??你知道吗
相关问题 更多 >
编程相关推荐