'.py files in google colab

How can upload and run .py files in Google Colab? I can open the file as text and run it after copying, but I want to know if there is a way I can upload the .py file directly? (It is only possible to upload an .ipynb file this way, and when I upload the .py file, it gives an error and does not open the file.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source