📜  在 Python 代码示例中将 csv 转换为字典

📅  最后修改于: 2022-03-11 14:46:07.930000             🧑  作者: Mango

代码示例3
pythonCopyimport csv

mydict = {}

with open('csv_file.csv', mode='r') as inp:
    reader = csv.reader(inp)
    dict_from_csv = {rows[0]:rows[1] for rows in reader}

print(dict_from_csv)