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.
     
    ---------------------

  • 相关阅读:
    iOS使用技能
    iOS 视频播放的简单使用
    iOS中二维码的生成与使用(入门篇)
    正则表达式的小总结
    最近项目中巧遇的几个好工具,分享一下
    Foundation与coreFoundation的相互转换
    iOS实用技能扩展-集成支付宝
    iOS实用技能扩展-静态库的制作与简单使用
    数据存储的三种方式
    Magento获取IP地址
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11211006.html
Copyright © 2011-2022 走看看