zoukankan      html  css  js  c++  java
  • C++猿的Python笔记01

      注释前缀 #  

    #!/usr/bin/python
    #Filename:helloworld.py
    print 'Hello Python.'


      字符串  

    1. '和"是一样的

    2. '''用来定义多行字符串,并且其中可自由使用'和"

    >>> print '''This is a multi-line string. this is 1st line.
    this is second line.
    "what's ur name?", I asked.
    "my name is fourth line!".'''
    This is a multi-line string. this is 1st line.
    this is second line.
    "what's ur name?", I asked.
    "my name is fourth line!".

    >>>   

    3. 转义字符 \

    4. 自然字符串前缀,r或R

        自然字符串:即不识别转义字符的串。

    5. Unicode字符串前缀,u或U

    6. 放在一起的字符串会自动级联

    7. ,分开的输出内容,和级联类似,但会自动添加一个空格 

    >>> print 'this is' "a sentence."
    this isa sentence.
    >>> print 'this is',"a sentence."

    this is a sentence. 

      语句分隔  

    用 ; 或 物理行的结束 来表示语句的结束。

    但通常在py中看不到分号 ;

    = 5
    print i

    = 5;print i

    = 5;print i;

    = 5;
    print i;

      程序块的划分  

    使用缩进来表示程序的层次

    建议用 单个制表符两或四个空格 

      

      运算符   

    1. **,幂,x**y,返回x的y次幂.

    2. //, 整除。返回商的整数部分。

    3. ~,按位翻转,~x返回-(x+1), ~5得到-6。

    4. not,and,or,逻辑运算符。

  • 相关阅读:
    Redis主从复制及主从复制的注意事项
    Redis哨兵(Sentinel)
    Redis慢查询日志(slowlog)
    Memcached缓存雪崩现象
    PHP添加Memcached扩展
    Redis节省空间
    Memcached遇到的问题及解决办法
    C++ explicit关键字学习
    力扣:排序之topK||Kth元素的问题
    软聚类
  • 原文地址:https://www.cnblogs.com/mumuliang/p/2130918.html
Copyright © 2011-2022 走看看