Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在python中,我目前正在这样做:
if user_can_read(request.user, b) == False:
有没有其他方法可以检查函数是否返回False?
False
你可以使用
if user_can_read(request.user, b): ## do stuff
如果user_can_read返回任何值(除了 0、False 等),它将被视为 True,并执行操作。
user_can_read
和否定:if not user_can_read(request.user, b)
if not user_can_read(request.user, b)