Ministério da Educação
Brasil um país de todos
Personal tools
You are here: Home Members Cicero Garrozi Disciplinas 2014 em diante Introdução à Programação Arquivos 2015-2 Algoritmos slides10-ex2-linhas-enumeradas.txt
Navigation
Log in


Forgot your password?
 
Document Actions

slides10-ex2-linhas-enumeradas.txt

by Cicero Garrozi last modified 2014-06-03 07:04

Click here to get the file

Size 1 kB - File type text/plain

File contents

1 import os
2 f = open("pessoas.txt", "r")
3 dic = {}
4 for linha in f:
5     pos = linha.find(" ")
6     identidade = linha[:pos]
7     nome = linha[pos+1:-1]
8     dic[identidade] = nome
9 pasta = os.getcwd()
10 print "Pasta atual: "+ pasta
11 f.close()
12 
13 print dic
14 for chave, valor in dic.iteritems():
15     print "Identidade: %s\tNome: %s"%(chave, valor)
16     

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: