Recently, I started studying Python on my own.
I'm still so immature that I can't even call you a beginner, but I'm sorry to ask you this question.
I use Eclipse.
I wrote the following code in the open() function.
open_file=open('point.txt')
raw_data=open_file.read()
open_file.close()
print(raw_data)
point.txt is in the same folder, and the results of the loading are displayed when running in the Eclipse app, but when you run it at the command prompt,
open_file=open('point.txt')
FileNotFoundError: [Errno2] No such file or directory: 'point.txt'
The file does not exist.
Is the Eclipse setting not working?
Sorry for the rudimentary question.
By the way, Eclipse uses PyDev.
If you specify the current directory in cd and run it, it will open.
If you put a full pass in the first line as shown below, it will work wherever the prompt is.
Also, the prefix 'r' or 'R' treats the backslash as literal characters.
open_file=open(r'D:\abc\efg\point.txt')
© 2024 OneMinuteCode. All rights reserved.