神交python已久,干中学——2语法
python语法:
1.字符串:
'、"、""",很随意
格式化:%d,%s,%f
快速格式化:f"{变量}"
转义:\
2.注释
#单行
"""多行
3.数据类型转换
int(x)、float(x)、str(x)
4.关键字
True False class from raise None continue for return def global nonlocal
and del if try as elif import while assert else in with break except is yield
5.运算符
+、-、*、/、//(取整)、%(取余)、**(指数)
6.输入
input("")
7.空格缩进
4个空格
8.判断
if、elif、else
9.循环
while
for...in...
for... in range():多参数不包含后面的
10.函数
def 函数:
a. def func(a,b,c)
b. def func(a=1,b=2,c=3)
c. def func(*args)
d. def func(**kwargs)
e. def func( func_name )
f. def func( lambda x,y : x+y)