-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdict1.py
More file actions
43 lines (36 loc) · 787 Bytes
/
dict1.py
File metadata and controls
43 lines (36 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 pi <pi@raspberrypi>
#
# Distributed under terms of the MIT license.
"""
"""
people = {
'bob': {
'phone': '2341',
'addr': 'usa'
},
'tom': {
'phone': '4444',
'addr': 'qiaotou'
}
}
label = {
'p': 'phone',
'a': 'addr'
}
user=input('Please input name: ')
if user in people:
type = input("Please input phone(p) or addr(a)")
user = user.strip().lower()
type = type.strip().lower()
if type in label:
key = label[type]
value = people[user][key]
print("%s %s is %s" % (user, key, value))
else:
print("please input p or a")
else:
print("Please input collect name")