标签:
3-10
#!/usr/bin/env python # encoding: utf-8 import os ls = os.linesep fname = raw_input(‘Enter file name: ‘) all = [] try: fobj = open(fname, ‘r‘) print "‘%s already exists‘" % fname except IOError, e: print "\nEnter lines (‘.‘ by itself to quite). \n" while True: entry = raw_input(‘>‘) if entry == ‘.‘: break else: all.append(entry) fobj = open(fname, ‘w‘) fobj.writelines(‘%s%s‘ % (x, ls) for x in all) fobj.close() print "Done!"
标签:
原文地址:http://www.cnblogs.com/ohmydenzi/p/5451419.html