Quick Tip: Run any Python script as a module with python -m
Hey fellow Python devs, have you ever stumbled upon a Python script and wondered how to run it as a module? Well, wonder no more. The python -m command is here to save the day.
This handy command allows you to run any Python script as a module, and it's super useful for a variety of tasks. For example, need a quick HTTP server? Run python -m http.server and you're good to go. This will start a simple HTTP server in your current directory, perfect for testing or serving up some static files.
Another great example is python -m json.tool. This command will pretty-print any JSON data you
Follow me on Dev.to for daily Python tips and quick guides!
If you found this useful, you might like Python Automation Scripts Pack (10 Ready-to-Use Tools) — a practical resource that takes things a step further. At $19.99 it's a solid investment for your toolkit.
喜欢这篇文章?关注获取更多Python自动化内容!
🔒 Want More?
This article covers the basics. In Content Creator Ultimate Bundle (Save 33%) ($29.99), you get:
- Complete source code
- Advanced techniques
- Real-world examples
- Step-by-step tutorials
- Bonus templates
Top comments (0)