码迷,mamicode.com
首页 > 编程语言 > 详细

python-if else流程判断--006

时间:2018-03-07 18:53:11      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:hello   bin   判断   user   年龄   port   false   orm   and   

一、密码输入不显示

方法:getpass

Import  getpass

username = input("username:")

password = getpass.getpass("password:")

print(username,password)

结果输出:

[root@i-ekowjial~]#./hello.py

username:user

password:

(‘user‘,‘123‘)

[root@i-ekowjial~]#

二、if判断

#Author:RobinWen

_username = "Robin"

_password = "123456"

username = input("username:")

password = input("password:")

if_username == username and _password == password:

print("Welcome user {name} logo in!".format(name=username))

else:

print("Invalid username or password!")

结果输出:

(1)True

username:Robin

password:123456

Welcome user Robin logo in!

(2)False

username:Robin

password:111

Invalid username or password!

三、年龄猜测-if判断

#Author:RobinWen

my_age=25

guess_age = int(input("Age:"))

if guess_age == my_age:

print("yes,you got it!")

elif guess_age > my_age:

print("bigger...")

else:

print("smaller...")

 

python-if else流程判断--006

标签:hello   bin   判断   user   年龄   port   false   orm   and   

原文地址:https://www.cnblogs.com/bazingafraser/p/8523717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!