I have this simple code
def main():
ff = open("../text_learning/test_email.txt", "r")
when I try to run it in Visual Studio code I get this error:
IOError: [Errno 2] No such file or directory: '../text_learning/test_email.txt'
But when I run it from cmd it works.
Any idea why the Visual Studio code is causing troubles?
The dir tree:
└───ud120-projects
├───.vscode
├───choose_your_own
├───datasets_questions
├───decision_tree
├───evaluation
├───feature_selection
├───final_project
│ └───emails_by_address
├───k_means
├───naive_bayes
├───outliers
├───pca
├───regression
├───svm
├───text_learning
├───tools
└───validation
The Visual Studio code is opened to the root directory (ud120-projects).
os.path.dirname(__file__)