Python 学习 02:语句
运算符
算数运算符
=,+,-,*,/,//,**,%
+=,-=,*=
比较运算符
==,!=,>,<,>=,<=
逻辑运算符
and,or,not,xor,nor
成员运算符
in,not in
位运算符
&,|,^,~,<<,>>
赋值运算符
=
链式赋值
m = n = 'Python'
解包
a, b, c = (1, 2, 3)
身份运算符
is,is not
if 条件语句
1 | if condition1: |
pass 语句:空语句,是为了保持程序结构的完整性。pass 不做任何事情,一般用做占位语句。
三元操作符:A = X if condition else Y
for 循环
1 | for condition: |
range(begin, end, step) 函数:返回一个以 step 为步长从 begin 到 end 左闭右开的序列。
while 循环
1 | while condition: |
while 和 for 的区别:for 用来遍历,while 用来判断条件。
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment










