jupyter在windows下读取非C盘文件报错FileNotFoundError: [Errno 2]

it2022-05-09  34

问题描述

想用anaconda内置的jupyter进行机器学习训练,文件路径没有错,用os.path.exists(file_path)尝试检测文件路径,文件夹路径没有错返回值为True,但文件的返回值总是为False,更别提读取文件了,被这个问题困扰了很久。

data = pd.read_csv(“D:\py-program practice\FBlocation\test.csv”)

FileNotFoundError: [Errno 2] File b'D:\\py-program practice\\FBlocation\test.csv' does not exist: b'D:\\py-program practice\\FBlocation\test.csv'

解决方法

windows读取文件时,文件夹的路径可以不加斜杠,但是文件名需要加斜杠

data = pd.read_csv(“D:\py-program practice\FBlocation\test.csv”)


最新回复(0)