@echo off rem 下面把空格去掉 set t=a a a a a a set t=%t: =% echo %t% echo. rem 下面把b换成a set t=abababababa set t=%t:b=a% echo %t% pause 结果为: 转载于:https://blog.51cto.com/xfqxj/1075139