15 lines
265 B
Python
15 lines
265 B
Python
b = {1:'张三', 2:'老王', 3:'王五'}
|
|
|
|
def select(sid):
|
|
# 判断sid这个id是否是字典的键
|
|
if sid in b:
|
|
return b[sid] # 根据键取值
|
|
else:
|
|
return None
|
|
|
|
if __name__ == '__main__':
|
|
|
|
print(select(1))
|
|
print(select(2))
|
|
|