遍历容器字典中的值(浮点数)

Iterating through values (floats) in a container dictionary

如何遍历字典中的浮点值?

我有一个字典,它的多个值是我想根据键重命名的文件名。

for k,v in dictionary.iteritems():
print(k,v)

这给了我这个输出:

键.........,值

(20026308, u'1224, 1225')

...

现在我想对每个值说,检查目录中是否存在同名文件。

photodir = "C:\Desktop\phototest" photosindir = glob.glob("C:\Desktop\phototest*.jpg")

import os
photodir = "C:\Desktop\phototest"
dict = {20026308 : u'1224, 1225'}
for k,v in dict.items():
    print(k,v)
    for photo_id in v.split():
        path_to_check = "C:\Desktop\phototest%s.jpg"%photo_id
        photo_exist = os.path.isfile(path_to_check)
        print(path_to_check, "exists : ", photo_exist)

给出:

20026308 1224, 1225
C:\Desktop\phototest1224,.jpg exists :  False
C:\Desktop\phototest1225.jpg exists :  False