Windows下bat脚本积累 无限间隙循环打印 @echo off :start cls for /f "delims=" %%i in ( 'netstat -nao^| find /C "3306" ') do set MYIP=%%i for /f "delims=" %%i in ( 'netstat -nao^| find /C "TIME" ') do set TIME_WAIT=%%i for /f "delims=" %%i in ( 'netstat -nao^| find "28080"^| find /C "TIME" ') do set SOAP_WAIT=%%i for /f "delims=" %%i in ( 'netstat -nao^| find "3306"^| find /C "TIME" ') do set SQL_WAIT=%%i echo 3306端口数量:%MYIP% echo 等待端口数量:%TIME_WAIT% echo WEB服务等待端口数量:%SOAP_WAIT% echo 数据库等待端口数量:%SQL_WAIT% echo ------------------------------------------------------------------------------- #等待间隙1秒 choice /t 1 /d y /n >nul goto start cmd进去UTF-8编码格式 #查看当前编码格式 chcp #输出936,为GBK编码格式 #utf-8编码对应编号为65001 chcp 65001 #进入UTF-8编码活页 #在运行PYTHON脚本就不会因为乱码报错了