#写入文件
import os
ls=os.linesep #系统的换行符
while True:
fname=raw_input("Please input file name ")
if os.path.exists(fname):
print "the file already exists"
else:
break
all=[]
print "\nEnter lines . to quit\n"
while True:
entry=raw_input(">")
if entry=='.':
break
else:
all.append(entry)
#读取文件
fname=raw_input('Please enter the filename to read: ')
try:
fobj=open(fname,'r')
except IOError,e:
print "*** file open error: "+e
else:
for eachLine in fobj:
print eachLine,
fobj.close()