How would I work with files on my own computer?


#1

Question

How would I work with files on my own computer?

Answer

On Codecademy, all of the files you work with will be in the directory (folder) you’re currently working in, making the opening of files very easy. You just write the name of the file! However, if you want to try working on your computer with files at some point, the process is a bit more complicated because you’ll need to learn to write relative file paths.
A relative file path tells the program how to navigate from the file you wrote that line of code in, like script.py, to the file you want to open().
To become familiar with navigating around your computer’s directory structure, I’d recommend going through our Learn the Command Line course.
And to set up Python on your own computer, check out our guide to setting up Python on your computer.


Learn Python - File Input / Output - See It to Believe It