• Python学习笔记


    1.  python 获取帮助 例如help('print') 退出帮助q键

    2.  注释使用#

    print('hello world') #注意到print是一个函数
    3. 52.3E-4 其中E表示10的幂,python没有单独的long类型,int类型可以指任何大小的整数。

    4. 可以使用单引号和双引号指定字符串

    ‘将我这样框进来’或‘Quote me on this’ "what's your name ?"

    5. 使用三个引号"""或者'''来指定多行字符串

    6. 打印print函数,格式化打印方法.format()

    # str_format.py

    age = 20
    name = 'Swaroop'

    print('{0} was {1} years old when he wrote this book'.format(name, age))
    print('why is {0} playing with that python?'.format(name))

    print('{} was {} years old when he wrote this book'.format(name, age))
    print('why is {} playing with that python?'.format(name))
    7. print默认加换行符 ,可以用end=''指定以空白结尾

    8. 转义字符, 制表符。

    9. 很长的代码可以用反斜杠拆成多个物理行

    10. r或R来指定原始(Raw)字符串

    r"Newlines are indicated by "
    11. 变量(variables) 不需要声明或者定义数据类型

    12. python将程序中的任何内容统称为对象(object)

    13. 默认一个物理行就是逻辑行,若指多逻辑行加分号(;),不建议这样用

    14. 缩进4个空格表示一个语句块

    # var.py
    i = 5
    print(i)
    i = i + 1
    print(i)

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

    输出:

    5
    6
    This is a multi-line string.
    This is the second line.
     
    ---------------------

  • 相关阅读:
    开发Django项目01
    本地安装python2.x和python3.x双版本之后怎么使用pip
    python3.x并发编程
    centos6.8安装JDK1.8教程
    yum安装MySQL指定版本
    python爬虫爬取get请求的页面数据代码样例
    python网络爬虫学习笔记
    python通过get方式,post方式发送http请求和接收http响应-urllib urllib2
    CentOS7.5安装python-pip报Error: Nothing to do解决方法
    文件操作
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11211006.html
Copyright © 2020-2023  润新知