错误提示:
=========== RESTART: C:\Users\menyongzhen\Desktop\py脚本\copyread.py ===========
Enter filename: D:\software\python
*** file open error: [Errno 13] Permission denied: 'D:\\software\\python'
>>>
源代码:
#!/usr/bin/env python
#_*_coding:utf8_*_
'readTextFile.py -- read and display text file'
#from makeTextFile import fobj
#get filename
fname = input('Enter filename: ')
print
#attempt to open file for reading
try:
fobj = open(fname,'r')
except IOError as e:
print ("*** file open error: ",e)
else:
#display contents to the screen
for eachLine in fobj:
print (eachLine,)
fobj.close()