import shelve
name = input('Please enter your name: ')
reg = input(Please enter the registration plate: ')
speed = input(Please enter the speed: ')
Dictionary = {name:{reg:speed}}
db = shelve.open('Data')
db['Stuff'].append(Dictionary)
db.close
f = shelve.open('Data', 'r')
print(f['Stuff'])
f.close()
我不确定如何附加字典'Stuff'
。如果有人可以告诉我如何使用shelve
附加字典,因为我没有任何线索。
答案 0 :(得分:1)
import shelve
name = input('Please enter your name: ')
reg = input('Please enter the registration plate: ')
speed = input('Please enter the speed: ')
Dictionary = {name:{reg:speed}}
db = shelve.open('Data')
db['Stuff'].append(Dictionary)
db.close
f = shelve.open('Data', 'r')
print(f['Stuff'])
f.close()