Python3中的hasattr()

Python3已经将此内置函数移除了。查阅Python v3.0 documentation发现可以使用

hasattr(object, name)内置函数来完成callable的功能,方式如下:

3.0之前:callable(func)

3.0之后:hasattr(func, '__call__')

这两者结果是相同的。

posted on 2017-12-21 21:24  EdWin_E  阅读(255)  评论(0编辑  收藏  举报

导航