Last active
October 13, 2015 17:27
-
-
Save moacirmoda/5c93a5887142238593f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# abrindo o arquivo para leitura | |
with open('test.txt') as handle: | |
# criando uma variável para armazenar a quantidade de linhas | |
lines = 0 | |
# iterando, linha por linha, no aquivo de leitura | |
for line in handle: | |
# incrementando a variável de linhas | |
lines += 1 | |
# localizando a posição da palavra, caso não exista retorna -1 | |
find_string = line.find('ante') | |
# verifica se foi algo localizado, se sim, printa o resultado na tela | |
if find_string > 0: | |
print "linha %s, coluna %s" % (lines, find_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eget tempor diam. Sed rutrum convallis enim, | |
sit amet placerat orci tempus vel. Phasellus ornare nisl tortor, vitae convallis velit hendrerit eu. Lorem ipsum dolor sit amet, consectetur | |
adipiscing elit. Duis rutrum enim at varius scelerisque. Fusce commodo, lectus at tincidunt vulputate, mi ante viverra est, sed sollicitudin justo | |
lacus et libero. Etiam placerat varius nibh ut congue. Curabitur pellentesque varius semper. Nullam id vestibulum tortor. Nullam eget pharetra ex. In | |
fringilla, est at porttitor faucibus, magna nulla malesuada metus, eu finibus lorem elit a ipsum. Pellentesque molestie metus eu viverra ultricies. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment