Latest web development tutorials

Python inclui exercícios 97

Python 100 Li Python 100 Li

Título: Digite alguns caracteres no teclado, colocá-los um por um até o disco até que você digite uma data #.

Análise do Programa: Nenhum.

Source Code:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    from sys import stdout
    filename = raw_input('input a file name:\n')
    fp = open(filename,"w")
    ch = raw_input('input string:\n')
    while ch != '#':
        fp.write(ch)
        stdout.write(ch)
        ch = raw_input('')
    fp.close()

O exemplo acima saída é:

input a file name:
a
input string:
b
b
c
c#

Python 100 Li Python 100 Li