2while

一.while

1.while 死循环
f=True
while f:
    print(1)
print(2)
知识兔
2.while 活循环
①.正序
count = 1
while count <= 5:
    print(count)
    count += 1
知识兔
②.倒序
count=5
while count:
    print(count)
    count-=1
知识兔
3.break continue
while True:
    print(1)
    print(2)
    break
    print(3)
print(4)

1
2
4
知识兔
while True:    print(1)    print(2)    continue    print(3)print(4)1212...
4.若果 循环 否则 while else
while True:    print(1)    breakelse:    print(2)

二.数字里非零的都是Ture

print(bool(0))

三.字符串的格式化

1.项目—名片
用户输入的内容和开发者预留的内容拼接 然后一起输出的方法
①.加法拼接
a="name:"b="age:"c="job:"d=input("名:")e=input("龄:")f=input("工:")print(a+d+"\n"+b+e+"\n"+c+f)
②.字符串格式化拼接
m='''name:%sage:%sjob:%s'''a=input("名:")b=input("龄:")c=input("工:")print(m%(a,b,c))
m='''name:%sage:%djob:%s'''a=input("名:")b=int(input("龄:"))c=input("工:")print(m%(a,b,c))
③要输出一句 A层1 以下四种方法
b=input("输:")a="A层:"print(a+b)
b=input("输:")a="A层:%s"print(a%(b))
a=f"A层{1}"print(b)
b=input("层:")a=f"A层{b}"print(a)

四.运算符

1.赋值运算符
①.自加
a=10a+=1print(a)
②.自乘
a=10a*=2print(a)
2.逻辑运算符
①. and 安真后 安假钱 安逸假
print(0 and 1)
②.or 傲真浅 傲假吼 奥义真
print(0 or 1)
③.优先级: ()>not>and>or
print(9 and 1 or not False and 8 or 0 and 7 and False)
3.成员运算符 in not in
s="als"print("ls" in s)True
s="als"if "ls" in s:    print(True)else:    print(False)    True
计算机