zoukankan      html  css  js  c++  java
  • Python学习1

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    # Filename : helloworld.py
    print u'使用单引号定义字符串'
    print u"使用双引号定义字符串"
    print u'''使用三引号创建换行
    第二行
    第三行'''
    print u'使用转义符\''
    print u'使用行末\来连接太长的一行字符串\
    过长部分字符串'
    print ur'使用r创建自然字符串过滤转义符\''
    print u'Unicode符'
    print u'两个字符串自动连接' u'第二个字符串'
    print u'欢迎到中国来!Hello World\''

    # var
    i = 5
    print i
    i = i + 1
    print i

    s = '''This is a multi-line string.
    This is the second line.'''
    print s

    s = u'创建逻辑行,不以分号结尾'
    print s

    print \
          s

    # calc
    print 2//3
    print 20/3
    print 20//3
    print 20//3.0
    print 20/3.0
    print 2<<2
    print 3<<2
    print 4<<2
    print 3>>2
    print 4>>2
    print 5>>2
    print 6>>2
    print 5&3
    print 5^3
    # 加号比与或符优先级高
    print 5&3 + 5^3 == 5|3
    print 5&3 + 5^3
    print (5&3) + (5^3)
    print 5|3
    print ~5
    # x的值与y的值互换
    x = 5
    y = 3
    x = x ^ y
    y = y ^ x
    x = x ^ y
    print x
    print y
    x = ~(~0<<4)
    y = x >> 4
    print y & x
    # 循环移位
    a = ~0
    b = a << (8 - 4)
    c = a >> 4
    c = c | b
    print c
    a = 0xAA
    b = a << (8 - 4)
    c = a >> 4
    c = c | b
    print c,a
    a = 0x55
    b = a << (8 - 4)
    c = a >> 4
    c = c | b
    print c,a

  • 相关阅读:
    [zjoi]青蛙的约会_扩展欧几里德
    [coci2012]覆盖字符串 AC自动机
    出题日志
    [zjoi2003]密码机
    矩阵乘法
    洛谷 P1064 金明的预算方案
    洛谷 P1656 炸铁路
    洛谷 P1049 装箱问题
    最长上升子序列(LIS)与最长公共子序列(LCS)
    求最大公约数与最小公倍数
  • 原文地址:https://www.cnblogs.com/si812cn/p/1740243.html
Copyright © 2011-2022 走看看