"""
键盘输入key 与 value,通过调用模块OrderdDict,按照输入顺序存储字典表
"""
from collections import OrderedDict
class DictTest3:在这里插入代码片
dict_value = OrderedDict()
def __init__(self, key='', value=''):
self.key = key
self.value = value
def Input_Dict(self):
self.key = input('Enter key: ')
self.value = input('Enter value: ')
return self.key, self.value
def dict_Input(self):
while self.key:
self.dict_value[self.key] = self.value
self.key = ''
self.value = ''
return self.dict_value
def prit_dict(self):
print(self.dict_value)
dict1 = DictTest3()
active = True
while active:
dict1.Input_Dict()
if dict1.key == 'quit':
dict1.prit_dict()
break
elif dict1.key == '':
dict1.prit_dict()
break
else:
dict1.dict_Input()