Python_day03_01_昨日回顾.txt 1. 变量 s = 'qf' 先创建对象,之后把名字分配给这个对象。 等号右边的对象先被创建或者被获取 a = b = c = 1 a, d = 1,2 a = 1 b = 2 a ---2 b ---1 c = a a = b b = c a, b = b, a # a, b = 2, 1 a --- 2 b --- 1 2. 运算符 n = 1 n += 1 n += 2 10 // 3 10 % 2 10 % 3 3.逻辑运算符 and or not in 4. 比较运算符 == > < >= <= != 5. if ...: pass if ...: pass else: pass for i in ...: pass while ...: pass 6. 字符串 s = 'www.qfduc.ocm' s = s.split('.', 1)[0] 反向切割 s.rsplit() 开头查找 s.startswith() 结尾查找 s.endswith() 移除字符串头尾指定的字符串(默认为空格或换行符) s.strip() input(">>:").strip() ---------------- while True: ... else: pass for i in ...: ... else: pass 字符串的替换 s.replace() s.replace(old, new[, max]) 返回字符串中的old(旧字符串)替换成new(新字符串)后生成的新字符串,如果指定第三个参数max,则替换不超过max次。 any all not () list tuple dict set