SyntaxFix
Write A Post
Hire A Developer
Questions
By dictionary comprehension
d = { line.split()[0] : line.split()[1] for line in open("file.txt") }
Or By pandas
import pandas as pd d = pd.read_csv("file.txt", delimiter=" ", header = None).to_dict()[0]