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()