import asyncio
async def upload_img(line):
print(line)
async def _main():
with open('tmp_img_list.txt') as file:
await asyncio.gather(*(
upload_img(v.strip()) for v in file.readlines()
))
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(_main())
loop.close()
list(filter(lambda x: x, lst))
from itertools import zip_longest
t = ['K', 'G', 'K', 'G', 'G', 'K', 'K']
new_list = [list(v) for v in zip_longest(t[::2], t[1::2], fillvalue='K')]
print(new_list)
from collections import defaultdict
dan = [[5, 1], [10, 1], [30, 2], [20, 2]]
result = defaultdict(int)
for v, k in dan:
result[k] += v
print(result)