3 回答
TA贡献1852条经验 获得超7个赞
我尝试使用正斜杠和双反斜杠。两者都有效。
'C:\\Users\\SAVK\\Downloads\\Ex_Files_Intro_Data_Science\\Ex_Files_Intro_Data_Science\\Exercise Files\\state_baby_names.csv'
'C:/Users/SAVK/Downloads/Ex_Files_Intro_Data_Science/Ex_Files_Intro_Data_Science/Exercise Files/us_baby_names.csv'
例子 :
states_babies = pd.read_csv('C:\\Users\\SAVK\\Downloads\\Ex_Files_Intro_Data_Science\\Ex_Files_Intro_Data_Science\\Exercise Files\\state_baby_names.csv');
states_babies = pd.read_csv('C:/Users/SAVK/Downloads/Ex_Files_Intro_Data_Science/Ex_Files_Intro_Data_Science/Exercise Files/us_baby_names.csv');
TA贡献1842条经验 获得超21个赞
如果作者直接调用该文件,则它位于运行 Jupyter Notebook 的同一文件夹中
以下之一应该可以从不同位置调用文件:
一个。用双引号替换单引号并转义斜杠 ex。csvFile = "C:\\Users\\...\\myData.csv"
湾。用双引号替换单引号并使用正斜杠 ex。csvFile = "C:/Users/.../myData.csv"
TA贡献1906条经验 获得超3个赞
我通过将 Google Colab 安装到 Google Drive 解决了这个问题。这是我挂载到 Google Drive 后的路径:
csvFile = '/content/drive/My Drive/Colab Notebooks/myData.csv.txt'
xmlFile = '/content/drive/My Drive/Colab Notebooks/myData.xml'
添加回答
举报