readTextFile.py

 

运行后一堆空白行

 

>>> fname=input('Enter filename:')
Enter filename:hongding
>>> try:
    fobj=open(fname,'r')
except(IOError,e):
    print('***file open error:',e)
else:
    for eachLine in fobj:
        print(eachLine,)fobj.close()
        
SyntaxError: invalid syntax
>>> fname=input('Enter filename:')
Enter filename:hongding
>>> try:
    fobj=open(fname,'r')
except(IOError,e):
    print('***file open error:',e)
else:
    for eachLine in fobj:
        print(eachLine,)
    fobj.close()

 

posted @ 2015-07-25 16:22  hhj187  阅读(112)  评论(0编辑  收藏  举报