Latest web development tutorials

Pythonは演習97と、

Pythonの100リー Pythonの100リー

タイトル:あなたは日付#を入力するまで、ディスクまで一つずつを入れて、キーボードから文字をいくつか入力します。

プログラム解析:なし。

ソースコード:

#!/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()

上の例の出力は、次のとおりです。

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

Pythonの100リー Pythonの100リー