In: Computer Science
how do I move a file from downloads to a .py file
I'm trying to read and write on a text file in Python I want to know how to get that file in Python directory
To move any file (it may be a text file or a python file) from one folder to other, follow these steps:
In windows:
1. Right click on the file that you want to move.
2. Click on cut/copy ('cut' removes the selected data from its original position, while the 'copy' creates a duplicate; in both cases the selected data is kept in temporary storage (the clipboard)).
3. Go to the folder where you want to move the file to.
4. Right click on the screen and click on paste.
In Linux:
'mv' command helps user to move file from one location to other.
syntax: mv <source-filepath> <destination-filepath>
example: mv "C:\Users\File_Name.txt" "C:\Users\SubFolder\File_Name.txt"
Note: Extension of the file(.txt, .py) should be mentioned to move the file from one location to another in linux.
Once you get the text file from downloads to the python directory, you can read and write in the text file by mentioning only the name and extention of the file in the python code.
You can also read and write the text file from anywhere by mentioning the path of the text file in the python code.