python IOError: [Errno 13] Permission denied: 'csv_test.csv'
源码:# coding:utf-8
import csv
csvfile = file('csv_test.csv','wb')
writer = csv.writer(csvfile)
writer.writerow(['姓名', '年龄', '电话' ])
data = [
('小何', '25', '123456789'),
('小芳', '18', '123789')
]
writer.writerows(data.decode('utf-8').encode('gbk'))
csvfile.close()
错误信息:
D:\python\python.exe E:/其他/new/test_csv.py
Traceback (most recent call last):
File "E:/����/new/test_csv.py", line 3, in <module>
csvfile = file('csv_test.csv','wb')
IOError: Permission denied: 'csv_test.csv'
Process finished with exit code 1
相关资料:
当你不能满足被访问文件所设置的权限时,也会引发IO Error错误,
类似这样IOError: Permission denied: 'c:/a.txt' python permission denied
从字面意思来理解就可以知道原因了,是因为我们执行的命令(运行python文件等),没有权限,
给一个超级管理员权限就可以了。
应该怎么解决呢
页:
[1]