批处理for中字符串截取必须先把循环变量代替出来才行!!!

@echo off & setlocal enabledelayedexpansion
  set ifo=abc,def,ghi,jkl,mnopqrstuvwxyz0123456789
  echo 原字符串(第二行为各字符的序号):
  echo %ifo%
  echo.
  echo 截取前5个字符:
  echo %ifo:~0,5%
  echo 截取最后1个字符:
for /f "delims=," %%a in ("%ifo%") do (
set x=%%a
echo !x!
set y=!x:~-1!
echo !y!
)
pause

上一篇:c#多线程同步之Semaphore


下一篇:Django搭建网站笔记