Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person(dict):
- def __init__(self, name, surname, address, phone, email):
- self.name = name
- self.surname = surname
- self.address = address
- self.phone = phone
- self.email = email
- def __repr__(self):
- return f'{self.name} {self.surname} - {self.address} - { self.phone } - {self.email}'
- def toJson(self):
- import json
- return json.dumps(self.__dict__)
- personList = []
- personList.append(
- Person("Mario", "Rossi", "Via dei tonni 69", "334949493", "mario@rossi.it")
- )
- personList.append(
- Person("Giovanni", "Paperoni", "Via dei paguri 1", "12344532", "john@pag.it")
- )
- for person in personList:
- print(person)
- print(person.toJson())
Add Comment
Please, Sign In to add comment