# query class
Python 3.6 pycharm Run (ERR)
people = {
' Wang Fei ': {
' phone ': ' 2341 ', '
' address ': ' Western town of Forget Chuan Cun '
},
' small flat three ': {
' phone ' : ' 9102 ',
' address ': ' Bliss Palace town, Prince Edward village 111th '
},
' Mitchell ': {
' phone ': ' 3158 ',
' address ': ' conveniently refer to the village of the Tathagata community a block 7 Building 2-storey Nishi '
}
}
KK = 0
Print ("The system can only query the population of xxx County, only for the time being rotation")
while True:
If KK < 3:
NA me = input (' Please enter the name to query: ')
If name in people:
REQUESR = input (' Please enter phone number (p) or address (a): ')
if requesr = = ' P ': requesr = ' phone '
if requesr = = ' a ': REQUESR = ' address '
person = people.get (name, {})
result = Person.get (REQUESR)
Print ("\t\t{} Home {} is: {}". Format (name, REQUESR, result))
KK + = 1
Continue
If KK = 3:
Break
Else:
Print ("The user has not logged ...")
Operation Result:
The system can only query the population of xxx County, only in the rotation of the way to inquire
Please enter the name to query: Wang Fei
Please enter your phone number (p) or address (a): a
The address of Wang Fei home is: Western Forget Chuan Cun
Please enter the name you want to query: small flat three
Please enter your phone number (p) or address (a): P
Small flat three phone number is: 9102
Please enter the name to query: Mitchell
Please enter your phone number (p) or address (a): a
Mitchell Home address is: Shun Finger Township Tathagata community a block 7 building 2-storey West
Jump out of the loop (exit the program)
python3.6 Small Program