1d = {}
2with open("file.txt") as f:
3 for line in f:
4 (key, val) = line.split()
5 d[int(key)] = val
6
1def get_pair(line):
2 key, sep, value = line.strip().partition(" ")
3 return int(key), value
4
5with open("file.txt") as fd:
6 d = dict(get_pair(line) for line in fd)
7