Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- import sys
- import time
- ver = '0.0.2-a'
- if len(sys.argv) > 1:
- if sys.argv[1] == '-v':
- print('Versão: %s' % (ver))
- print('\t\t\t\tExemplos:')
- print('Se versão contém \'a\' (é alpha), \'b\' (é beta) ou \'rc\' (é release-candidate).')
- sys.exit(0)
- else:
- print('Argumento não é valido. Desculpe-nos!')
- def loading(msg, tempo, pular_linha=False):
- '''
- FAZ O PROCESSO DE "LOADING"
- '''
- if pular_linha == 1:
- print('\n%s' % (msg), end='')
- else:
- print('%s' % (msg), end='')
- for x in range(tempo):
- sys.stdout.write('.')
- sys.stdout.flush()
- time.sleep((tempo / 5.8) / 12)
- print('')
- def contador_palavras(texto):
- '''
- LITERALMENTE CONTA AS PALAVRAS
- '''
- try:
- loading('Carregando', 5)
- texto = len(texto.split())
- if texto > 1:
- print("O texto tem %d palavras" % (texto))
- else:
- print("O texto tem %d palavra" % (texto))
- except KeyboardInterrupt:
- loading('Saindo', 3, True)
- sys.exit(0)
- except Exception:
- print('exception', Exception)
- def main():
- '''
- EXECUTA TODAS AS FUNÇÕES ANTERIORES
- '''
- try:
- texto = input("Digite um texto qualquer: ")
- if len(texto) < 1:
- pass
- else:
- contador_palavras(texto)
- except KeyboardInterrupt:
- loading('Saindo', 3, True)
- sys.exit(0)
- while 1:
- main()
Advertisement
Add Comment
Please, Sign In to add comment