Quick Tip: Run any Python script as a module with python -m
Hey fellow Python enthusiasts! Today I want to share a simple yet powerful tip that can save you time and increase your productivity. Did you know you can run any Python script as a module using the python -m command?
This command allows you to execute a Python module as a script, without having to navigate to the script's location or worry about the PYTHONPATH. Let's look at a few examples:
- Need a quick HTTP server? Run
python -m http.serverand you'll have a server up and running in no time. - Working with JSON data? Use
python -m json.toolto pretty-print and validate your JSON files
Follow me on Dev.to for daily Python tips and quick guides!
🔗 Recommended Resources
- Python Crash Course — 3-10%
Note: Some links are affiliate links. Using them supports this blog at no extra cost to you.
🛠️ Useful resource: **Content Creator Ultimate Bundle (Save 33%)* — $29.99. Check it out on Gumroad!*
喜欢这篇文章?关注获取更多Python自动化内容!
Top comments (0)