python的基本语法
变量的定义
变量名 = 值
列:age = 18
标识符
什么是标识符
开发人员在程序中自定义的一些符号和名称
标识符是自己定义的,如变量名 、函数名等
标识符的命名规则
标识符只能由字母、下划线“_”、数字组成。
标识符不能以数字开头。
标识符不能使用关键字 。
标识符对大小写敏感。
python的关键字
‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘async’, ‘await’, ‘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
标识符的命名方法
小驼峰
函数名 addName
大驼峰
类名 AddName
python的输入和输出
输入:
input(“提示信息:”)
输出:
print(“输出的信息:”)
换行:
\n
格式化输出
使用百分号(%)字符串格式化
使用format字符串格式化
注释
单行注释:#
多行注释:’’’
或者 :"””