计算机二级考试(Python)__变量、命名、保留字

1、变量

变量是保存和表示数据值的一种语法元素。

在Python中,变量能够随时命名、随时赋值、随时修改。

2、命名

Python采用大写字母、小写字母、数字、下划线和汉字等字符及其组合进行命名,支持汉字。

注意:

    1.标识符大小写敏感

    2.标识符中间不能出现空格

    3.标识符首字符不能是数字

    4.并不能和保留字相同

    5.从兼容性和编程习惯考虑,一般不采用汉语等非英语语言命名变量

3、保留字

Python 3.x版本共有35个保留字,如下:

Python的35个保留字列表
and as assert async await break class
continue def del elif else except False
finally for from global if import in
is lambda None nonlocal not or pass
raise return True try while with yield

Python二级计算机考试设计的保留字有22个:

    False、True、and、as、break、continue、def、del、elif、else、except、for、from、global、if、import、in、not、or、return、try、while

猜你喜欢

转载自blog.csdn.net/qq_40721085/article/details/113620575