主页 » WEB开发 » SQLAlchemy中的expression类型与None相等

SQLAlchemy中的expression类型与None相等

2008-04-02添加留言

在SQLAlchemy中,无论你要找的字段table.c.name,还是你的查询条件table.c.id==1,都是一个表达式expression。
但这里有一个陷阱,这些expression居然和None相等: None==expression

所以判断时,要使用绝对等于 expression is None (相当于其他语言的===)
其实Python中的普通表达式是不等于None的,不信你试试 1+2==None

No related posts.

以上关联文章由 Yet Another Related Posts Plugin 提供支持。

相关文章

发表评论