其他分享
首页 > 其他分享> > isinstance

isinstance

作者:互联网

isinstance

def daniel(value):
    if isinstance(value,dict):////
   用来判断是不是这个类型的fuction
        suga = sum(value.values())/len(value)
    else:
        suga = sum(value)/len(value)
    return suga


mifa={"cc":12,"bb":22,"cc":33}
mifa1=[2,3,4]
print(daniel(mifa1))
>>> isinstance(3,int) 
True

返回布尔值

标签:cc,sum,suga,value,daniel,isinstance
来源: https://blog.csdn.net/weixin_44932344/article/details/111597483