Quick Tip: Run any Python script as a module with python -m
Hey fellow devs, have you ever stumbled upon a Python script and wondered how to run it as a module? Look no further! The python -m command is here to save the day. This handy flag allows you to run any Python script as a module, and it's incredibly useful.
For example, let's say you want to quickly spin up a simple HTTP server. Instead of installing a separate package, you can use the built-in http.server module: python -m http.server. This will start a server in your current directory, and you can access it by navigating to http://localhost:8000 in your browser.
Another
Follow me on Dev.to for daily Python tips and quick guides!
喜欢这篇文章?关注获取更多Python自动化内容!
Top comments (0)