会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
微风伏面
首页
管理
2017年10月25日
python __nonzero__方法
摘要: 类的nonzero方法用于将类转换为布尔值。通常在用类进行判断和将类转换成布尔值时调用。比如语句if A: print 'foo'中就会调用A.nonzero()来判断。下面这个程序应该能帮助你理解nonzero的作用。 class A: def __nonzero__(self): print '
阅读全文
posted @ 2017-10-25 11:03 fredgui
阅读(3274)
评论(0)
推荐(0)
公告