python 判断变量名能否调用

res = 'jack'


def index():
return 123


ret = callable(res)
ret2 = callable(index)

print(f'ret:{ret}') # ret:False
print(f'ret2:{ret2}') # ret2:True
posted @ 2023-10-19 17:14  tslam  阅读(5)  评论(0编辑  收藏  举报