#发文福利#
#!/usr/bin/env python
# -*- coding:utf-8 -*-
students = {'id001': {'name': 'serena', 'age': 18, 'address': 'beijing'},'id002': {'name': 'fanbingbing', 'age': 42, 'address': 'anhui'},'id003': {'name': 'kahn', 'age': 20, 'address': 'shanghai'}}
class Student:
def __init__(self, xid, name, age, address):
self.xid = xid
self.name = name
self.age = age
self.address = address
result = []
# #实例化对象的同时给对象传参。
for k,v in students.items():
student = Student(k, v['name'],v['age'],v['address'])
result.append(student)
for i in result:
print i.xid,i.name,i.age,i.address
# id001 serena 18 beijing
# id002 fanbingbing 42 anhui
# id003 kahn 20 shanghai
------------听哥一句劝,不要做运维----------------2023年9月7日23:46:15-------