---恢复内容开始---
1.while 循环
while -- 关键字 while 条件: 缩进循环体(代码块)
死循环 ### 条件一直为真,形成一个死循环
条件为真,while Ture:
while 3>2: user = input("请输入用户名") password = input("请输入密码") print(user,password)
#break 是跳出循环
while 3>2: print(555) break print(22) print("11")
结果为555
"11"
不进入死循环
# continue 是跳出本次循环继续下次循环(临时见底,当做代码块中最后一行)
while 3>2: print(555) continue print(22) print("11")
跳过continue以下的代码,直接进入循环,所以结果是555的无限循环
利用while循环,得到10以内数字
count = 1 while 10 > count: print(count) count = count + 1
利用while循环,得到(1,2,3,4,5,6,8,9)
count = 1
while 10 > count: if count == 7:
count = count+1
print(count)
else:
print(count)
count = count + 1
while 条件: 缩进循环体(代码块) else: 缩进代码块
#while else是一体的,如果while判断条件不成立就执行
else代码,参考if else
while 条件: 缩进循环体 代码块
2.运算符
5种
算数运算符
+
-
*
/
**幂次方
//整除(没有小数点)
比较运算符
>
<
>=
<=
==
!=不等于
赋值运算符
=
a +=10 >>> a=a+10
-=
*=
/=
**=
//==
%=
逻辑运算符
与 and # and两边的条件都为真的时候成立
或 or # or 两边的条件只要有一个为真就是真
非 not # 遇真则假,遇假则真
#数字做and计算,and前后数字不为0的时候,取and后面的数字
否则取0
#数字做or计算 ,不为0取前面的, 不取0
#优先级 () > not > and > or
成员运算符
in # 在
not in #不在
s = "我"
ss = input"请输入内容"
if s in ss:
print(2)
3.初始编码
0 - 255
ASCII码 不支持中文
python2 默认编码 ASCII码
Unicode 万国码 16位(2字节)
中文4字节
英文2字节
utf-8 最少使用8位(1字节) 欧洲16位(2字节) 亚洲24位(3字节)
utf-16 最少使用16位(2个字节)
gbk(国标 国家标准)
gbk 中文 2个字节
英文 1个字节