DJ49 DJ49 - 1 year ago 85
Python Question

Read this file and create a dictionary with keys of the type tuple and values of the type float

abcdefghijklmnopqrstuvwxyz try this as list and string and then dictionary and also tuple

Answer Source
with open(filename) as f:
    d = {tuple(x.split(':')[0].strip().split(',')): float(x.split(':')[1].strip()) for x in f}

This is a (fairly complex) dictionary comprehension.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download