|
改过了可是还是不行。。
print('please input a dict')
def input_dict():
dic = {}
key = input('Input key:')
i=input('nest? yes/no')
if i == 'yes':
dic1 = {}
while True:
key1 = input('Input key:')
if key == '':
break
value1 = input('Input value:')
dic1[key1] = value1
dic[key]=dic1
else:
while True:
value = input('Input value')
key = input('Input key')
if key =='':
break
dic[key] = value
return dic
dict=input_dict()
print(dict)
但是如果只构成一个没有嵌套的字典是可以执行的
dic = {}
while True:
key = input('Input key:')
if key == '':
break
value = input('Input value:')
dic[key] = value
print(dic) |
|