为列表创建3个对象并打印

import re
user_list = []
while True:
if len(user_list) < 3:
user = input('请输入用户名:')
pwd = input('请输入密码:')
email = input('请输入邮箱:')
check_email = re.compile(r'\w+(@live.com)')
ret = check_email.match(email)
if ret:
class person:
def __init__(self):
self.user = user
self.pwd = pwd
self.email = email
obj = person()
user_list.append(obj)
else:
print('邮箱格式有误')
else:
for i in user_list:
print('我叫%s,邮箱是%s' %(i.user, i.email))
break
 
posted @ 2020-02-15 15:19  冰灬荷  阅读(223)  评论(0编辑  收藏  举报