Python run directory or zip file

If you put a __main__.py file in the root directory of your project file, you can use the root directory to run the entire program.

Your project looks like this ex.

app/
 |-test.py
 |-test2.py
 |-__main__.py
 

You can run the program like this

>> python app

The interpreter will execute the __main__.py file as the main program.

If you package the code into a zip file, the same will work.

ex.

>> cd app/
>> zip -r test.zip *.py
>> python test.zip

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325316570&siteId=291194637
Recommended