python – Shorten dict comprehension with repeated operation


dc = {line.split('=')(0): line.split('=')(1) for line in txt}

Below avoids duplication but is even longer:

dc = {k: v for line in txt for k, v in
      zip(*map(lambda x: (x), line.split('=')))}

Any better way? Just without any imports.


Context: with open('config.txt', 'r') as f: txt = f.read().split('n')

a=1
bc=sea
>>> {'a': '1', 'bc': 'sea'}  # desired output; values should be string