如何访问项目根文件夹

2024-10-04 05:28:22 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我的项目截图。虽然我可以用pd.read_csv("./_files_inner/games.csv")很容易地访问我的_files_inner文件夹,但我发现访问我的“根”文件夹_files很棘手

如果您看到我的projectexplorer,我试图访问_files,但没有指定绝对路径(即C:\\Users\\adhg\\dev\\py\\_files\\games.csv),因为其他开发人员有不同的路径。你知道吗

问题:如何访问根_files文件夹(不起作用)pd.read_csv("./_files/games.csv")

import pandas as pd

csv_result = pd.read_csv("./_files/games.csv")  #will not work
csv_result = pd.read_csv("./_files_inner/games.csv") #works 

print csv_result

enter image description here


Tags: csv项目pydev文件夹readfilesresult