If I have a file directory like this:
-Proj
- Proj.py
- Directory
- input.txt
and Proj.py wants to read from input.txt, how can I get to it? open() seems to only take an absolute address.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Relative paths are relative to the current working directory, which is usually the directory your shell was in when you invoked the python interpreter.
Use something like