Python学习总结----基础篇7
表达式
一、if….else
1.用户登录验证案例
#author=ykyk
import getpass
name = input("请输入用户名:")
passwd = input("请输入密码:")
if name == 'ykyk' and passwd == '123456':
print("welcome to New world!",name)
else:
print('invalid username or password!')
二、for循环
#author=ykyk
for i in range(10):
if i < 5:
print(i)
else:
print(i-5)
三、while循环
死循环
#author=ykyk
count = 0
while True:
print('我再也不能见你在深夜里买醉,不愿别的男人看见你的妩媚')
count +=1
加循环条件
#author=ykyk
count = 0
while True:
print('我再也不能见你在深夜里买醉,不愿别的男人看见你的妩媚')
count +=1
if count == 113:
print('single dog!')
break
Nothing is true,Nothing is fake.