• 数据运算


    算数运算:

    image

    比较运算:

    image

    赋值运算:

    image

    逻辑运算:

    image

    成员运算:

    image

    身份运算:

    image

    位运算:

    image

    #!/usr/bin/python
      
    a = 60            # 60 = 0011 1100
    b = 13            # 13 = 0000 1101
    c = 0
      
    c = a & b;        # 12 = 0000 1100
    print "Line 1 - Value of c is ", c
      
    c = a | b;        # 61 = 0011 1101
    print "Line 2 - Value of c is ", c
      
    c = a ^ b;        # 49 = 0011 0001 #相同为0,不同为1
    print "Line 3 - Value of c is ", c
      
    c = ~a;           # -61 = 1100 0011
    print "Line 4 - Value of c is ", c
      
    c = a << 2;       # 240 = 1111 0000
    print "Line 5 - Value of c is ", c
      
    c = a >> 2;       # 15 = 0000 1111
    print "Line 6 - Value of c is ", c

    *按位取反运算规则(按位取反再加1)  

    详解http://blog.csdn.net/wenxinwukui234/article/details/42119265

    运算符优先级:

    image

    三元运算:

    result = 值1 if 条件 else 值2

    如果条件为真:result = 值1

    如果条件为假:result = 值2

    进制:

    二进制,01

    八进制,01234567

    十进制,0123456789

    十六进制,0123456789ABCDEF 二进制到16进制转换

    http://jingyan.baidu.com/album/47a29f24292608c0142399cb.html?picindex=1

  • 相关阅读:
    绍一集训Round#2
    CF 799B T-shirt buying
    Luogu P2827 蚯蚓
    Luogu P4053 [JSOI2007]建筑抢修
    【LGR-049】洛谷7月月赛
    浅谈可持久化数据结构
    CF 888E Maximum Subsequence
    在平衡树的海洋中畅游(三)——Splay
    浅谈单调栈/队列
    CF 859E Desk Disorder
  • 原文地址:https://www.cnblogs.com/sleeping-cat/p/9224362.html
Copyright © 2020-2023  润新知