-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.py
More file actions
35 lines (26 loc) · 652 Bytes
/
file.py
File metadata and controls
35 lines (26 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Pessoa():
def __init__(self, nome, idade, email):
self.nome = nome
self.idade = idade
self.email = email
def __str__(self):
return 'nome: %s' % (self.nome)
def __repr__(self):
return 'Pessoa <%s>' % str(self)
def read():
f = open('dados.csv', 'r')
pessoas = []
for i in f:
p = i.split(',')
pessoa = Pessoa(p[0], p[1], p[2])
pessoas.append(pessoa)
print(pessoa)
print(pessoas)
return pessoas
def write():
pessoas = read()
f = open('pessoas.txt', 'w')
for i in pessoas:
f.write(str(i) + '\n')
f.close()
write()