Importing a file while writing a program is one of the important tasks. As we have many types of files like CSV file, text file, python file, etc. So we have to do different things to import different files.
We import the file as we can use that file’s code in our program.
For importing csv file we have to import CSV.
For python file we can easily import it by its name.
import my_file #use my_file in your program.
Python file has extension as .py file. It should be located in that directory in which we are writing our new program.
In this way we can import file in python.