D
D
Daniil Aleksandrovich2018-08-22 22:04:11
Python
Daniil Aleksandrovich, 2018-08-22 22:04:11

Not sure why it crashes?

I am a beginner Python programmer. Faced with the fact that the file in the directory does not want to be determined.
Here are the pictures:
5b7db36ea75e0300501116.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-08-22
@Danchik2005

The working directory is the one in which the script is run. In your case it is C:\Users\111. All relative paths are built from the working directory. That is, it open("text.txt", "r")will try to open C:\Users\111\text.txt, while it is available at the path E:\Project_2018\text.txt Either run the script in the same directory where the required file is located, or use absolute paths, or write code to get the location of a script and build relative paths from it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question