python-if else流程判断--006

Posted bazingafraser

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python-if else流程判断--006相关的知识,希望对你有一定的参考价值。

一、密码输入不显示

方法:getpass

Import  getpass

username = input("username:")

password = getpass.getpass("password:")

print(username,password)

结果输出:

[[email protected]~]#./hello.py

username:user

password:

(‘user‘,‘123‘)

[[email protected]~]#

二、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的主要内容,如果未能解决你的问题,请参考以下文章

python-if

006-shiro授权

first-Python基础判断语句006

if else流程判断

is else流程判断

python中if else流程判断