Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
PYTHON - 我想从 csv 文件的行中输入数据的前两个元素。例如,1,3,4 是 CSV 文件的第一行,我想制作一个元组字典,其中前两个数字 (1,3) 作为键,值是第三个数字 (3)。所以输出看起来像这样,
{('1','3') : 4}
您面临的困难是什么?发布您尝试过的代码。以下内容应该可以解决问题:
d={} fp=open("csv","r") for i in fp.readlines(): d[(i[0],i[2])]=i[4]