Python库中“隐藏”的小工具

在Python的标准库中,有一些是可以直接通过命令行运行的小工具,它们简单而又实用,以下列举我常用到的几个:

SMTP服务器:

python -m smtpd -n -c DebuggingServer localhost:25

CGI服务器:

python -m CGIHTTPServer 80

HTTP服务器:

python -m SimpleHTTPServer 80
# Python3
python -m http.server 80

JSON格式化 :

echo '{"no":123}' | python -m json.tool

我们可以查找所有可执行的Python库:

grep -r  "if __name__ == '__main__'" /path/to/python/libaray/

参考链接

    原文作者:我不是风哥
    原文地址: https://www.jianshu.com/p/6eb16f9163a5
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞