[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

第三题

  1. @echo off
  2. set yyy=bbs bathome.net
  3. echo %yyy%
  4. for /f "tokens=1" %%i in ("%yyy%") do echo %%i
  5. (for /f "tokens=1 delims=." %%i in ("%yyy%") do echo %%i) >1.txt
  6. for /f "tokens=2" %%i in (1.txt) do echo %%i
  7. for /f "delims=. tokens=2" %%i in ("%yyy%") do echo %%i
  8. pause
复制代码

TOP

第四题

  1. @echo off
  2. cls
  3. for /f "tokens=1-3" %%i in (test.txt) do echo %%i %%j  %%k
  4. for /f "tokens=2"  %%i in (test.txt) do echo %%i
  5. pause
复制代码

TOP

第四题再发,刚没注意路径

  1. @echo off
  2. cls
  3. for /f "tokens=1-3" %%i in (f:\test.txt) do echo %%i %%j  %%k
  4. for /f "tokens=2"  %%i in (f:\test.txt) do echo %%i
  5. pause
复制代码

TOP

第三题也可以是这样子

  1. @echo off
  2. set xxx=bbs buthome.net
  3. for /f "tokens=1-3 delims=. " %%i in ("%xxx%") do set s1=%%i && set s2=%%j && set s3=%%k
  4. echo %s1%
  5. echo %s2%
  6. echo %s3%
  7. pause>nul
复制代码

TOP

  1.                 for  /l %i% in (1.1.100) do echo %i%
  2.                           for  /l %i% in (1.2.99) do echo %i%
  3.                
复制代码

TOP

1.
  1.   for /l %%i in (1.1.100) echo %%i
  2.   
复制代码
2.
  1.   for /l %%i in (1.2.99) echo %%i
  2.   
复制代码
3.
  1.   @ echo off
  2.   set "str=bbs bathome.net"
  3.   echo %str%
  4.   for %%i in (%str%) do echo %%i
  5.   
复制代码

TOP

第四题
  1. @ echo off
  2. for /f "tokens=*" %%i in (f:\test.txt) do echo %%i
  3. for /f "tokens=2" %%i in (f:\test.txt) do echo %%i
  4. pause
复制代码

TOP

五個題目按順序依次執行
  1. @echo off
  2. for /l %%a in (1,1,100) do echo %%a
  3. pause>nul
  4. for /l %%a in (1,2,99) do echo %%a
  5. pause>nul
  6. set str="bbs bathome.net"
  7. for /f "tokens=1 delims==. " %%a in (%str%) do echo %%a
  8. for /f "tokens=2 delims==. " %%a in (%str%) do echo %%a
  9. for /f "tokens=3 delims==. " %%a in (%str%) do echo %%a
  10. pause>nul
  11. for /f "tokens=1-3 delims==" %%a in (test.txt) do echo %%a
  12. pause>nul
  13. for /f "tokens=2 delims== " %%a in (test.txt) do echo %%a
  14. >nul
  15. @echo on
复制代码

TOP

第四个问题的

  1. @echo off
  2. color a
  3. for /f "delims=." %%i in (1.txt) do echo %%i
  4. echo _______________________________________
  5. for /f "tokens=2" %%i in (1.txt) do echo %%i
  6. pause
复制代码

TOP

  1. @echo off
  2. for /f "tokens=1 delims=. " %%a in ("bbs bathome.net") do echo %%a
  3. for /f "tokens=2 delims=. " %%b in ("bbs bathome.net") do echo %%b
  4. for /f "tokens=3 delims=. " %%c in ("bbs bathome.net") do echo %%c
  5. pause>nul
复制代码

TOP

有疑问的是第三题,只看了第一页的帖子,为什么大家都不设置delims,难道逗号也是默认分列符?反正在我的机器上不设置是不行的
  1. @echo off
  2. echo 第一题
  3. for /l %%i in (1,1,100) do echo %%i
  4. pause & cls
  5. echo 第二题
  6. for /l %%i in (1,2,99) do echo %%i
  7. pause & cls
  8. echo 第三题
  9. for /f "tokens=1-3 delims=. " %%i in ("bbs bathome.net") do (
  10. echo %%i
  11. echo %%j
  12. echo %%k
  13. )
  14. pause & cls
  15. echo 第四题①,这个可以不用for:
  16. type test.txt
  17. echo. & pause & cls
  18. echo 第四题②
  19. for /f "tokens=2" %%i in (test.txt) do echo %%i
  20. pause & cls
复制代码

TOP

  1. @echo off
  2. for /f "delims=" %%i in (1.txt) do echo %%i
  3. pause>nul
复制代码
  1. @echo off
  2. for /f "tokens=2,5,8" %%i in (1.txt) do echo %%i
  3. pause>nul
复制代码

TOP

第3题
  1. @echo off
  2. set txt=bbs bathome.net
  3. for /f "tokens=1-3 delims=. " %%i in ("%txt%") do (
  4. echo %%i
  5. echo %%j
  6. echo %%k
  7. )
  8. pause>nul
复制代码

TOP

  1. @echo off
  2. for /l %%i in (1,1,100) echo %%i
  3. pause
复制代码
  1. @echo off
  2. for /l %%i in (1,2,99) echo %%i
  3. pause
复制代码
  1. @echo off
  2. for /f "delims=, "
复制代码

TOP

  1. @echo off
  2. for /l %%i in (1,1,100) do echo.%%i
复制代码
第一题我也会做 哈哈

TOP

返回列表