批处理问题 以下命令 for ⼀l %%i in (01,1,99)do(echo %%i)如何能显示01 02 03 等,也就是说数字前边加0

2024-12-03 20:53:04
推荐回答(3个)
回答1:

@echo off
setlocal enabledelayedexpansion
for /l %%i in (1001,1,1999) do (
set x=%%i
echo !x:~-3!
)
pause

回答2:

@echo off&setlocal EnableDelayedExpansion
for /l %%i in (1,1,99) do (set i=0%%i
set i=!i:~-2!
echo !i!)

回答3:

do echo 0%%i
这样大于10前面也会加0了