Python pip建立pip.ini 修改为Aliyun源下载三方模块

"""
python建立pip.ini Aliyun源
2020年5月3日20:28:50 Venti Fang
"""

import os

ini = """
[global]
index-url = https://mirrors.aliyun.com/simple/
[install]
trusted-host=mirrors.aliyun.com
"""
pippath = os.environ["USERPROFILE"] + "\\pip\\"  #C:\Users\84788\pip\
# print(pippath)
if not os.path.exists(pippath):
    os.mkdir(pippath)

with open(pippath + "pip.ini", "w+") as f:
    f.write(ini)

相关推荐