python配置yum源
import subprocess import sys import os def main(): try: subprocess.call(["yum install wget -y;cd /etc/yum.repos.d/ && mkdir repo_bak && mv *.repo repo_bak/"], shell=True) subprocess.call(["wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo"], shell=True) subprocess.call(["yum clean all && yum makecache && yum repolist"], shell=True) sys.exit(0) except Exception as e: print(e) sys.exit(1) if __name__ == '__main__': main()