Python2中文出现乱码是因为内部采用的是utf8编码 而微软采用的是gbk

python3统一采用unicode

同时input输入的是字符串类型

new_inp=int(inp)输入1(数字)而不是字符串

inp=input("please input a number!")
new_inp=int(inp)
if new_inp==1:
print("You are right!")
else:
print('no!')

while...else系列 else仅一次
count=1
while count<10:
print("good!")
count=count+1
else:
print("bye!")
print("over!")
continue:跳过while下面 继续执行
count=0
while count<10:
if count==7:
count=count+1
continue
print(count)
count=count+1
break跳出当前循环 开始下一步循环
count=0
while count<10:
count=count+1
print(count)
break
print("over!")
三次问答:
count=0
while count<3:
inp = input("please input a number!")
new_imp = int(inp)

if new_imp==8:
print("YOU WIN!")
break
else:
print("YOU ARE WRONG!")
count = count + 1
print("over!")


posted on 2020-04-16 12:49  质料  阅读(93)  评论(0)    收藏  举报