Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python IO错误_Python_Ipython_Ioerror - Fatal编程技术网

Python IO错误

Python IO错误,python,ipython,ioerror,Python,Ipython,Ioerror,听起来很天真。我注意到了很多答案,但没有什么真正帮助我的情况 import csv from collections import defaultdict with open("aa_y_ss.csv", 'rb') as csvfile: allrows = csv.reader(csvfile, delimiter=',') for row in allrows: 抛出错误IOError:[Errno 2]没有这样的文件或目录 但是文件在目录中 我已使用以下工具检查了当前

听起来很天真。我注意到了很多答案,但没有什么真正帮助我的情况

import csv
from collections import defaultdict

with open("aa_y_ss.csv", 'rb') as csvfile:
    allrows = csv.reader(csvfile, delimiter=',')
    for row in allrows:
抛出错误IOError:[Errno 2]没有这样的文件或目录

但是文件在目录中

我已使用以下工具检查了当前目录:

import os
os.getcwd()
C:\\Users\\..\\Documents\\i笔记本电脑


为什么出现此错误?

为什么不尝试重命名文件?
我有一个类似的问题,我做到了。问题消失了

您的文件名为“文件名”吗?您能发布不起作用的确切代码吗?我刚刚添加了一个for循环,在该循环中我在文件中进行了一些计算,但错误在读取文件的那一行只是一些猜测:文件名的大小写是否正确,或者文件名是否如AA_Y_SS.CSV?此外,该文件是否有一个隐藏的扩展名,如aa_y_ss.csv.xls?另外,如果你创建一个文件,打开“bla”和“w”,它会进入同一个目录吗?既然你使用的是IPython,为什么不使用!dir*.csv在Python看到的当前目录中列出csv文件?