美文网首页
【Python】运算符

【Python】运算符

作者: Natsuka | 来源:发表于2018-08-22 18:36 被阅读6次
    基本运算符
    运算 符号 表达式
    + a+b
    - a-b
    * a*b
    / a/b
    取模(返回余数) % b%a
    ** a**b
    取整 // a//b
    比较运算符
    运算 符号 表达式
    等于 == (a==b)返回 False 或True
    不等于 != (a!=b)
    不等于 <> (a<>b)
    大于 > (a>b)
    小于 < (a<b)
    大于等于 >= (a>=b)
    小于等于 <= (a<=b)
    逻辑运算符
    运算 符号 表达式
    and (a and b) 如果a为False,返回False,否则返回b的计算值。a=10,b=20,返回值为20。
    or (a or b) 如果a非0,返回a的值,否则返回y的计算值。a=10,b=20,返回值为10。
    not not(a and b) 如果a为True,返回False。如果x为False,返回True。返回False。

    相关文章

      网友评论

          本文标题:【Python】运算符

          本文链接:https://www.haomeiwen.com/subject/obwyiftx.html