callable函数

# 判断对象是否可调用,可调用,即对象后加()

s = "abc"
ls = [1,2,3]

def f():
    pass

class F():
    pass

t =(s, ls, f, F)
for obj in t:
    if callable(obj):
        print(obj, True)
    else:
        print(obj, False)

 

posted @ 2019-01-31 10:21  怒放吧!  阅读(130)  评论(0编辑  收藏  举报
我的