我完全能够使用 pandas read_csv
用于在 Windows 中读取文件。但是我不知道如何在 Ubuntu 中设置本地路径?
如果我这样做:
data = pd.read_csv(r'file://home/gosper/Desktop/test.csv')
...它抛出错误:URLError: <urlopen error [Errno 2] No such file or directory
最佳答案
这应该适用于 Windows 和 UNIX 的桌面文件夹:
data = pd.read_csv(os.path.expanduser('~') + '/Desktop/test.csv')
关于python - 网址错误 : urlopen error [Errno 2] No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37787915/