Is there a way to work with files from a dictionary with similar names in a loop?

后端 未结 1 1799
深忆病人
深忆病人 2021-01-29 07:59

So, I was wondering if there could be a way to use files from a dictionary with similar names in a loop,

I have this dictionaries:

dcm = {}
for filename         


        
相关标签:
1条回答
  • 2021-01-29 08:47

    You can try iterate over dicts by zip() function like example bellow. It gives you list with all functions for all files. But don't forget than len of all dicts should be equals

    dcm = {'f1': 'path_to_file'}
    out = {'f1': 'path_to_file'}
    mtr = {'f1': 'path_to_file'}
    
    IFOV = []
    
    for d, o, m in zip(dcm, out, mtr):
        IFOV.append(
            gi.IFOV_generic(out[o], mtr[m], dcm[d], endpoint)
        )
    
    0 讨论(0)
提交回复
热议问题