[英]Comprehension list or map to improve performance?
Hello I'm trying to improve the performance of my code (find out a nice article here: http://leadsift.com/loop-map-list-comprehension/ ) 您好,我正在尝试提高代码的性能(在此处找到一篇不错的文章: http : //leadsift.com/loop-map-list-comprehension/ )
And I'd like to know if I can use a comprehension list in this part of my code: 我想知道我是否可以在代码的这一部分中使用理解列表:
for fmt in excels: xls_list.add(fmt) df_dict[fmt] = ''
excels = ['1.xls', '2.xls']
xls_list = set()
for fmt in excels:
xls_list.add(fmt)
df_dict[fmt] = ''
could be trasnformed into: 可以转换为:
xls_list = set(excels)
df_dict = dict.fromkeys(excels, '')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.