1、用shutil移动文件,import shutil shutil.move('/root/test.yaml','/home/') shutil.move('/root/k8s.py','/home/k8s.py.bak') 2、shutil删除目录shutil.rmtree("etcd-v3.3.9-linux-amd64")