python変換元
1202 ワード
pipソースの更新
引用自:PyPIは国内ソースを使用上のコードを.pyファイル として保存端末を開いて次のコマンドを入力
python(あなたのファイル名).py完了!
転載先:https://www.cnblogs.com/d-i-p/p/10553140.html
引用自:PyPIは国内ソースを使用
# coding: utf-8
import platform
import os
os_type = platform.system()
if "Linux" == os_type:
fileDirPath = "%s/.pip" % os.path.expanduser('~')
filePath = "%s/pip.conf" % fileDirPath
if not os.path.isdir(fileDirPath):
os.mkdir(fileDirPath)
fo = open(filePath, "w")
fo.write(
"[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
")
fo.close()
elif "Windows" == os_type:
fileDirPath = "%s\\pip" % os.path.expanduser('~')
filePath = "%s\\pip.ini" % fileDirPath
if not os.path.isdir(fileDirPath):
os.mkdir(fileDirPath)
fo = open(filePath, "w")
fo.write(
"[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
")
fo.close()
else:
exit("Your platform is unknow!")
python(あなたのファイル名).py完了!
転載先:https://www.cnblogs.com/d-i-p/p/10553140.html