python写了一个打开文件程序,无论文件都提示拒绝,连安装文件也不可以,我也是醉了,求救大神,多谢

错误提示:
=========== 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()

安装文件应该有后缀名exe的。
通常遇到Permission denied,方法有两个:一、把文件放在用户主目录(桌面、我的文档、%APPDATA%等),二、执行python的时候使用管理员身份运行。

你可以尝试一下读这个文件:C:\Users\menyongzhen\Desktop\py脚本\copyread.py
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答