1、查看python保留字
>>> import keyword >>> keyword.kwlist [‘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‘]
2、python中注释
(1)单行注释以 # 开
(2)多行注释可以用多个 # 号,还有 ‘‘‘ 和 """:
3、行与缩进
python最具特色的就是使用缩进来表示代码块,不需要使用大括号 {} 。
缩进的空格数是可变的,但是同一个代码块的语句必须包含相同的缩进空格数
缩进不一致报:IndentationError: unindent does not match any outer indentation level
4、多行语句
Python 通常是一行写完一条语句,但如果语句很长,我们可以使用反斜杠(\)来实现多行语句
total = item_one + item_two + item_three
在 [], {}, 或 () 中的多行语句,不需要使用反斜杠(\)
total = [‘item_one‘, ‘item_two‘, ‘item_three‘, ‘item_four‘, ‘item_five‘]
5、数字(Number)类型
python中数字有四种类型:整数、布尔型、浮点数和复数。
6、字符串(String)类型
原文:https://www.cnblogs.com/xinxin1994/p/10502516.html