items()
to iterate over a dictionary PTC-W0011df.items()
to iterate over the dictionary242 df = process5(fn)
243 elif fmt == "6":
244 df = process6(fn)
245 for plotid in df:246 database_save(df[plotid], uniqueid, plotid, project)
247
248
df.items()
to iterate over the dictionary773 elif fmt == "8":
774 df = process8(fn)
775 if isinstance(df, dict):
776 for plot in df:777 print(
778 ("File: %s[%s] found: %s lines for columns %s")
779 % (fn, plot, len(df[plot].index), df[plot].columns)
df.items()
to iterate over the dictionary336 elif fmt == "7":
337 df = process7(uniqueid, fn)
338 if isinstance(df, dict):
339 for plot in df:340 print(
341 ("File: %s[%s] found: %s lines for columns %s")
342 % (fn, plot, len(df[plot].index), df[plot].columns)
The preferred way to iterate over the key-value pairs of a dictionary is to declare two variables in a for loop, and then call dictionary.items()
(or dictionary.iteritems()
for Python2), where dictionary is the name of your variable representing a dictionary.'
details = {"first_name": "Alfred", "last_name":"Hitchcock"}
for key in details.keys():
print(key, d[key])
details = {"first_name": "Alfred", "last_name":"Hitchcock"}
for key, value in details.items():
print(key, value)