Posted on:
Last modified:
-m
is invokedIf you have a module foo
foo/
__init__.py
__main__.py
Then python -m foo
will execute __main__.py
cat some_json_file | python -m json.tool
zipfile.py -l zipfile.zip # Show listing of a zipfile
zipfile.py -t zipfile.zip # Test if a zipfile is valid
zipfile.py -e zipfile.zip target # Extract zipfile into target dir
zipfile.py -c zipfile.zip src ... # Create zipfile from sources
python -m gzip wordlist.txt # Will create wordlist.txt.gz
python -m gzip -d wordlist.txt.gz # Will extract to wordlist.txt
compare two directories
$ python -m filecmp /tmp/a /tmp/b
diff /tmp/a /tmp/b
Only in /tmp/a : ['1']
Only in /tmp/b : ['2']
Identical files : ['4']
Differing files : ['3']
Several modules lets you encode/decode in various formats:
For example:
$ echo 'secertpassword' | python -m encodings.rot_13
frpregcnffjbeq
python -m SimpleHTTPServer # 2
python -m http.server #3
python -m pydoc {module/func}
python -m cProfile script.py
python -m timeit script.py
python -m pstats script.py
python -m trace script.py
© 2016-2022 Yifei Kong. Powered by ynotes
All contents are under the CC-BY-NC-SA license, if not otherwise specified.
Opinions expressed here are solely my own and do not express the views or opinions of my employer.
友情链接: MySQL 教程站