一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

python if else语句学习笔记

时间:2014-06-21 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码
# -*- coding: cp936 -*-  #这里的意思是编码,当你文件中出现中文的时候就需要加上,否则会报错
username = raw_input("请输入用户名:");
password = raw_input("请输入密码:");
if username == "root" and password == "123":
    print "登录成功";
elif username == "root" and password != "123":
    print "密码错误";
elif username !='root' and password == "123":
    print "用户名错误";
else:
    print "俩都错了!";

热门栏目