Python includes exercises 97
Title: Enter a few characters from the keyboard, put them one by one up to the disk until you enter a date #.
Program Analysis: None.
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()
The above example output is:
input a file name: a input string: b b c c#