------------ restore the contents begin ------------
<! DOCTYPE HTML>
while loop
Loop: something that is constantly repeated cycle
while keywords
Infinite loop: while True:
Loop
while True: # 死循环#
print("坚强")#
print("过火")#
print("单身情歌")#
print("郭德纲的小曲")#
print("五环之歌")#
print("鸡你太美")#
print("大碗宽面")#
print("痒")
while the structure:
while conditions:
Indent loop
Control cycles: cycle number by controlling conditions
count = 0#
while True: # 死循环#
count = count + 1 # 先执行 = 右边的内容#
if count == 5:#
print(count)#
break # 有限循环
while loop in two keywords:
- break: terminate this cycle
- continue: out of this cycle, the next cycle continues (disguised as the last line of the loop)
- continue and break below the code will not be executed
while else
while else and if else similar
structure:
while conditions:
Indent loop
else:
Indent results
format
% S string:% is a placeholder, s represents the percentage contents into a string, you can fill in the numbers, or fill in a string
% D |% i: must be filled with digital
%% Escape: become common%
msg = "mountain brother, the current learning progress is% s %%"
print(msg%(2))
- Order of position correspondence (accounting for several positions to fill several positions)
f-string python3.6 version and above to use
a =1b =2msg = f"my name is {a} I'm {b} years old"print(msg)
Operators
Comparison Operators
# > < >= <= ==(等于) != (不等于)
Arithmetic Operators
# + - * / # //(整除|地板除(向下取整)) # ** 幂# % 取余(模) # print(5 / 2) # 2.5 # print(5 // 2) # 2 # print(2 ** 0) # 1 # print(5 % 2) # 1
Assignment Operators
# = # += # -=# *= # /=# //= # **= # %= # a = 10 # b = 2 # b += 1 # b = b + 1 # print(b) # a -= 1 # a = a - 1 # a *= 2 # a = a * 2 # a /= 2 # a = a / 2 # a //= 2 # a = a // 2 # a **= 2 # a = a ** 2 # a %= 2 # a = a % 2
Logical Operators
Take back and sides are true, or take the front, sides are false, and taking the front, back or takes and: to give a false false
or: a really really
# 与(and 并且) 或(or) 非(not 不是) # True and False # True or False # True and not False # 优先级:() > not > and > or # 查找顺序: 从左向右
Member operator
# in(在) not in(不在) # name = "alex" # msg = input(">>>") # if name in msg: # print(111) # else: # print(222)
The initial coding
# 编码集(密码本)
# ascii 不支持中文
# a 一个字符占用8位
# gbk(包含ascii)国标
# a 一个字符占用8位(1字节)
# 中文 一个字符占16位(2字节)
# unicode# 英文 4个字节 32位
# 中文 4个字节 32位
# utf-8 (最流行的编码集)
# 英文 1字节 8位
# 欧洲 2字节 16位
# 亚洲 3字节 24位
# 单位转换: # 1字节 = 8位 *****
# 1Bytes = 8bit *****
# 1024bytes = 1KB
# 1024KB = 1MB
# 1024MB = 1GB
# 1024GB = 1TB # 够用了
# 1024TB = 1PB
------------ restore the contents of the end ------------
<! DOCTYPE HTML>
while loop
Loop: something that is constantly repeated cycle
while keywords
Infinite loop: while True:
Loop
while True: # 死循环#
print("坚强")#
print("过火")#
print("单身情歌")#
print("郭德纲的小曲")#
print("五环之歌")#
print("鸡你太美")#
print("大碗宽面")#
print("痒")
while the structure:
while conditions:
Indent loop
Control cycles: cycle number by controlling conditions
count = 0#
while True: # 死循环#
count = count + 1 # 先执行 = 右边的内容#
if count == 5:#
print(count)#
break # 有限循环
while loop in two keywords:
- break: terminate this cycle
- continue: out of this cycle, the next cycle continues (disguised as the last line of the loop)
- continue and break below the code will not be executed
while else
while else and if else similar
structure:
while conditions:
Indent loop
else:
Indent results
format
% S string:% is a placeholder, s represents the percentage contents into a string, you can fill in the numbers, or fill in a string
% D |% i: must be filled with digital
%% Escape: become common%
msg = "mountain brother, the current learning progress is% s %%"
print(msg%(2))
- Order of position correspondence (accounting for several positions to fill several positions)
f-string python3.6 version and above to use
a =1b =2msg = f"my name is {a} I'm {b} years old"print(msg)
Operators
Comparison Operators
# > < >= <= ==(等于) != (不等于)
Arithmetic Operators
# + - * / # //(整除|地板除(向下取整)) # ** 幂# % 取余(模) # print(5 / 2) # 2.5 # print(5 // 2) # 2 # print(2 ** 0) # 1 # print(5 % 2) # 1
Assignment Operators
# = # += # -=# *= # /=# //= # **= # %= # a = 10 # b = 2 # b += 1 # b = b + 1 # print(b) # a -= 1 # a = a - 1 # a *= 2 # a = a * 2 # a /= 2 # a = a / 2 # a //= 2 # a = a // 2 # a **= 2 # a = a ** 2 # a %= 2 # a = a % 2
Logical Operators
Take back and sides are true, or take the front, sides are false, and taking the front, back or takes and: to give a false false
or: a really really
# 与(and 并且) 或(or) 非(not 不是) # True and False # True or False # True and not False # 优先级:() > not > and > or # 查找顺序: 从左向右
Member operator
# in(在) not in(不在) # name = "alex" # msg = input(">>>") # if name in msg: # print(111) # else: # print(222)
The initial coding
# 编码集(密码本)
# ascii 不支持中文
# a 一个字符占用8位
# gbk(包含ascii)国标
# a 一个字符占用8位(1字节)
# 中文 一个字符占16位(2字节)
# unicode# 英文 4个字节 32位
# 中文 4个字节 32位
# utf-8 (最流行的编码集)
# 英文 1字节 8位
# 欧洲 2字节 16位
# 亚洲 3字节 24位
# 单位转换: # 1字节 = 8位 *****
# 1Bytes = 8bit *****
# 1024bytes = 1KB
# 1024KB = 1MB
# 1024MB = 1GB
# 1024GB = 1TB # 够用了
# 1024TB = 1PB