一、pycharm安装
https://www.cnblogs.com/dcpeng/p/9031405.html
二,代码联系
1、输入输出(明文):
username = input("usrname:")
password = input("password:")
print(username,password)
2、输入输出(暗文):
import getpass ##输入的时候没有显示输入字符
username = input("usrname:")
password = getpass.getpass("password:")print(username,password)
3、验证输入的账号密码是否正确:
_username = ‘alex‘_password = ‘abc123‘username = input("username")password = input(‘password:‘)if _username == username and _password ==password: print("Welcome user {name} login...".format(name=username))else: print("Invalid username or password!")
4、猜年龄 if else
age_of_oldboy = 56guess_age = int(input("guess age:"))###输入必须为整数,不让报错if guess_age == age_of_oldboy: print("yes,you got it.")elif guess_age > age_of_oldboy: print("think smaller....")else: print("think bigger!") 5、while循环
count = 0while True: print("count:",count) count = count+1 if count ==100: break输出0-99
原文地址:https://www.cnblogs.com/hapen66/p/10963023.html
时间: 2024-10-11 15:15:37