1.数据运算
算数运算 | 整除运算:// 取余运算:% 指数运算:** |
赋值运算 | b+=a;等价于b=b+a |
比较运算 | >,<,==,!=,>=,<= |
逻辑运算符 | and 、or 、not 运算优先级:按照短路原则从左到右计算 条件1 and 条件2:如果条件1为假,python将不会再计算条件2,直接返回True 条件1 or 条件2:如果条件1为真,python将不会再计算条件2,直接返回True |
身份运算 | is 判断两个标识符是不是引自同一对象,如果是返回True is not 判断两个标识符是不是引自不同对象,如果不是则返回True |
成员运算 | in 如果在指定的序列能找到该值则返回True not in 如果在指定的序列找不到该值则返回True |
位运算 | &(与)、|(或)、~(取反)、^(异或)、>>(右移)、<<(左移) |
2. while循环
while 条件: 表达式 else: 表达式 |
break:终止循环 continue:跳出当次循环 |
例题:利用嵌套循环实现九九乘法表
3.制表符
\t
4.换行符
Linux:\n
win:\r\n
mac:\r
print()等效于print(end="\n")
print(end='-')等效于连字符(不换行)eg:a-b-c-