我得到在 python3 中运行此代码时未定义的错误名称:
def main():
D = {} #create empty dictionary
for x in open('wvtc_data.txt'):
key, name, email, record = x.strip().split(':')
key = int(key) #convert key from string to integer
D[key] = {} #initialize key value with empty dictionary
D[key]['name'] = name
D[key]['email'] = email
D[key]['record'] = record
print(D[106]['name'])
print(D[110]['email'])
main()
你能帮我解决这个问题吗?