what is python runpy module? [closed]

穿精又带淫゛_ 提交于 2020-01-04 07:25:09

问题


I was wondering the purpose of runpy module in Python and how does it help in day to day development of the Python user community?

Can someone please explain the necessity, usage and advantages of runpy module in python?


回答1:


The docs say:

The runpy module is used to locate and run Python modules without importing them first. Its main use is to implement the -m command line switch that allows scripts to be located using the Python module namespace rather than the filesystem.

You can run a python module like this:

python -m SimpleHTTPServer 8000

The runpy module enables this functionality. It may not be useful outside of this context.



来源:https://stackoverflow.com/questions/23629770/what-is-python-runpy-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!