Python基础-if判断以及其他循环

时间:2021-07-14 02:32:30

if else 判断:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import getpass
name = input("用户名??")
pwd = ("密码???")
if name=="xiaoli"and pwd=="cmd":
print('OK')
else:
print('用户名或密码错误!')

输出:

for i in range(10):
print("loop:",i)

While循环:

c = 0
while True:
print(c)
c +=1
if c==100:
print("循环100次结束!")
break