All pastes #1556783 Raw Edit

Untitled

public python v1 · immutable
#1556783 ·published 2009-09-07 05:22 UTC
rendered paste body
#!/usr/bin/env python# -*- coding: iso-8859-15 -*-import randomimport sysif __name__ == "__main__":    print "Script de escolha randomica de resultados"    if len(sys.argv) != 2:        print "Forma de uso: 'python sorteio.py arquivo.txt'"        exit(-1)    count = 0    for line in open(sys.argv[1]):        count += 1    resultado = random.randint(0,count);    count = 0    for line in open(sys.argv[1]):        if count == resultado:            print "{0}: '{1}'".format(resultado, line)            exit(0)        count += 1