Python 从行中的元素到键和值

Python 从行中的元素到键和值,python,Python,我有一个文件,上面有这样的行: no.3 normal yes 54 0,543 12 当我打印信息(第3号) 我从排队开始。但现在我不知道该怎么办 如我所见,我需要使用第一个元素作为键,其余元素作为值。 但我不知道从哪里开始 mydict = {} for line in myfile: items = line.split() # split line on whitespace mydict[items[0]] = items[1:]

我有一个文件,上面有这样的行:

no.3   normal   yes   54   0,543    12
当我
打印信息(第3号)

我从排队开始。但现在我不知道该怎么办

如我所见,我需要使用第一个元素作为键,其余元素作为值。 但我不知道从哪里开始

mydict = {}
for line in myfile:
   items = line.split()          # split line on whitespace
   mydict[items[0]] = items[1:]  # first item: key, rest: values
那你就可以了

print mydict["no.3"]
得到

['normal', 'yes', '54', '0,543', '12']

请把你已有的密码贴出来。