2024-05-23 22:48:31 发布
网友
你好,我正在尝试访问python中的excel文件。我用的是我们在课堂上学到的代码:
with open("file_name") as csv_file: csv_reader =csv.DictReader(csv_file)
每次我运行它都会得到相同的错误
PermissionError: [Errno 13] Permission denied: 'file_name'
我是否可以运行任何允许命令shell读取文件的代码?你知道吗
您需要用正确的路径和文件名更改file_name,即:
file_name
import csv with open("/home/user/path/to/file.csv") as csv_file: csv_reader = csv.DictReader(csv_file)
对于windows,将如下所示:
import csv with open("c:\\path\\to\\file.csv") as csv_file: csv_reader = csv.DictReader(csv_file)
您需要用正确的路径和文件名更改
file_name
,即:对于windows,将如下所示:
相关问题 更多 >
编程相关推荐