小编use*_*724的帖子

使用"和"作为回报

我正在攻读Udacity的Web应用工程课程.我注意到教师在他的验证方法中使用了andoperator in return语句.我不明白如何返回2个参数.我想,它可能像if声明.谁能解释它到底是什么?

这是验证方法:

USER_RE = re.compile(r"^[a-zA-Z0-9_-]{3,20}$")
def valid_username(username):
    return username and USER_RE.match(username)
Run Code Online (Sandbox Code Playgroud)

提前致谢.

python methods return python-2.7

7
推荐指数
1
解决办法
1504
查看次数

标签 统计

methods ×1

python ×1

python-2.7 ×1

return ×1