Python学习-4-基础知识点(未完待续)

1、基础语法java

一、注释:#注释,在eclipse中能够用Ctrl+/快捷键python

#!/usr/bin/python3
 
# 第一个注释
# 第二个注释
 
'''
第三注释
第四注释
'''
 
"""
第五注释
第六注释
"""
print ("Hello, Python!")

二、标识符:字母数字下划线,同java,数字不能打头;大小写敏感eclipse

三、保留字:spa

['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

四、行缩进code

python最具特点的就是使用缩进来表示代码块,不须要使用大括号 {} 。缩进的空格数是可变的,可是同一个代码块的语句必须包含相同的缩进空格数。three

五、多行语句ip

Python 一般是一行写完一条语句,但若是语句很长,咱们能够使用反斜杠(\)来实现多行语句字符串

total = item_one + \
        item_two + \
        item_three

在 [], {}, 或 () 中的多行语句,不须要使用反斜杠(\),例如:it

total = ['item_one', 'item_two', 'item_three',
        'item_four', 'item_five']

数字(Number)类型

python中数字有四种类型:整数、布尔型、浮点数和复数。class

  • int (整数), 如 1, 只有一种整数类型 int,表示为长整型,没有 python2 中的 Long。
  • bool (布尔), 如 True。
  • float (浮点数), 如 1.2三、3E-2
  • complex (复数), 如 1 + 2j、 1.1 + 2.2j

字符串(String)

  • python中单引号和双引号使用彻底相同。
  • 使用三引号('''或""")能够指定一个多行字符串。
相关文章
相关标签/搜索