# 用户注册案例:未封装场景
"""
user_list = [
{"name":"test","password":"1234},
{"name":"taaa","password":"1234},
]
"""
user_list = []
while True:
user = input("请输入用户名:").strip()
pwd = input("请输入密码:").strip()
if pwd.isupper() == 'Q':
break
info = {"name": user, "password": pwd}
user_list.append(info)
for item in user_list:
message = f"我的名字{item['name']},我的密码{item['password']}"
# 面向对象
class userInfo:
def __init__(self, name, password):
self.name = name
self.password = password
def show(self):
message = f"我的名字{item.name},我的密码{item.password}"
print(message)
user_list = []
while True:
user = input("请输入用户名:").strip()
pwd = input("请输入密码:").strip()
if pwd.isupper() == 'Q':
break
info = userInfo(user, pwd)
user_list.append(info)
for item in user_list:
item.show()