.txt文件的字典。如果给你一个.txt file
其中包含这些内容:创建从使用Python
James Doe 2/16/96 IT210 A BUS222 B PHY100 C
John Gates 4/17/95 IT101 C MATH112 B CHEM123 A
Butch Thomas 1/28/95 CS100 C MATH115 C CHEM123 B
你怎么能得到它,所以它需要的类名和成绩,并将它们放入一个空字典,而忽略其余?我的代码设置为读取.txt file
但卡住了。有什么建议么?
这是我打开文件代码:
def readFile():
new_dict = {}
myFile = open('Students.txt', 'r')
for line in myFile:
你能不能给我们的解释是什么样子在这种情况下的例子吗? –
该文件中的类名和等级是什么? –
Dict = {'IT210':'A','BUS222':'B','PHY100':'C'} – miloJ