python 中while 使用else实现双分支循环判断

----------------------------脚本部分-----------------------------
#!/usr/bin/env python
name = raw_input("please your name:")
while name == "bbs.52itw.com":
        print "name ok"
        break
else:
        print "name no"
---------------------------执行部分-------------------------------
[root@localhost opt]# python while_else.py 
please your name:ljp
name no
[root@localhost opt]# python while_else.py 
please your name:bbs.52itw.com
name ok
[root@localhost opt]#

你可能感兴趣的:(python,中while,使用else实现双分支循环判断)