发布时间:2019-08-06 09:14:09编辑:auto阅读(1376)
1、python中实现密码密文输入
#!/usr/bin/env python
import getpass #调用getpass模块就能实现密码密文显示
username=input("username:")
userpasswd=getpass.getpass("userpasswd:")
print(username,userpasswd)
2、if 判断
(1)、
#!/usr/bin/env python
_username = "lijinzhu"
_userpasswd = "abc123"
username = input("username:")
userpasswd = input("userpasswd:")
if _username == username and _userpasswd == userpasswd:
print("Welcome usr {name} login...".format(name=username))
else:
print("Invalid username or passwd!")
(2)、猜年龄
#!/usr/bin/env python
_age = 18
age = int(input("age:"))
if _age == age:
print("right")
elif _age > age:
print("think smaller...")
else:
print("think strong...")
#Note:
if 条件判断:
...
elif 条件判断:
...
else:
...
上一篇: Python Json
下一篇: Python 小工具 -实现简单文件对比
47494
45794
36793
34324
28968
25598
24443
19611
19111
17632
5466°
6048°
5570°
5638°
6573°
5376°
5378°
5884°
5855°
7170°