# -*- coding: UTF-8 -*-# 作者:幻灰龙# 标题:Python 函数调用# 描述:使用函数设计一组 “容器API”:init/set/get/existdefinit():return{}defset(dict,key,value):dict[key]=valuedefget(dict,key):returndict.get(key)defexist(dict,key):returndict.get(key)isnotNonedeftest():dict=init()foriinrange(10):key="key_{}".format(i)value=iset(dict,key,value)test_key="key_4"ifexist(dict,test_key):test_value=get(dict,test_key)print("key is: {}, value is: {}".format(test_key,test_value))if__name__=='__main__':test()