12
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user