Skip to content

common package and module in Python

  • 命令行:click, argparse

  • 并发:concurrent

  • 交互密码:getpass

  • 外部命令:subprocess, sh

  • 解析配置文件:configparse

  • 文件复制:shutil

import shutil
# Copy src to dst. (cp src dst)
shutil.copy(src, dst)
# Copy files, but preserve metadata (cp -p src dst)
shutil.copy2(src, dst)
# Copy directory tree (cp -R src dst)
shutil.copytree(src, dst)
# Move src to dst (mv src dst)
shutil.move(src, dst)

Reference

  • https://python-parallel-programmning-cookbook.readthedocs.io/zh_CN/latest/chapter4/06_Dealing_with_Asyncio_and_Futures.html
  • https://python3-cookbook.readthedocs.io/zh_CN/latest/c12/p09_dealing_with_gil_stop_worring_about_it.html

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback me#imzye.me, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try iOS App