zoukankan      html  css  js  c++  java
  • 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.
     
    ---------------------

  • 相关阅读:
    【VUE3.0体验】关于路由的一些坑
    TensorFlow中的卷积函数
    TensorFlow源码安装
    ubuntu远程桌面
    TensorFlow图像处理API
    C程序员眼里的Python
    深度剖析HashMap的数据存储实现原理(看完必懂篇)
    golang 互斥锁和读写锁
    golang goroutine的调度
    golang channel的使用以及调度原理
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11211006.html
Copyright © 2011-2022 走看看