首页 > 其他 > 详细

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

时间:2020-02-15 16:19:51      阅读:54      评论:0      收藏:0      [点我收藏+]
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
 

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

原文:https://www.cnblogs.com/hadibingjing/p/12312227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!