脚本自动安装python和pip,代码如下:

@echo off

setlocal EnableDelayedExpansion

set INSTALLER_PATH=%~dp0

set PYTHON_VERSION=3.9.5

set PYTHON_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-amd64.exe

set PYTHON_FILE=python-%PYTHON_VERSION%-amd64.exe

set PIP_VERSION=21.1.2

set PIP_URL=https://bootstrap.pypa.io/get-pip.py

echo Installing Python %PYTHON_VERSION%...

curl -s -L -o %INSTALLER_PATH%%PYTHON_FILE% %PYTHON_URL% %INSTALLER_PATH%%PYTHON_FILE% /quiet InstallAllUsers=1 PrependPath=1 Include_test=0

del %INSTALLER_PATH%%PYTHON_FILE%

echo Installing pip...

curl -s -L -o %INSTALLER_PATH%get-pip.py %PIP_URL%

python %INSTALLER_PATH%get-pip.py

del %INSTALLER_PATH%get-pip.py

echo Installation complete.

pause

05-08 17:19