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

[文本处理] [已解决]批处理怎么随机提取的字母啊?

  1. @echo off&setlocal enabledelayedexpansion
  2. for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  3.     set /a n+=1,a=!random!%%2
  4.     if !a! equ 0 (
  5.       set "_!random!!random!!random!=!n!"
  6.       ) else (
  7.       set "_!random!!random!!random!=%%i"
  8.    )
  9. )
  10. for /f "tokens=2 delims==" %%i in ('set _') do (
  11.     set /a n-=1
  12.     if !n! equ 15 pause>nul&goto :eof
  13.     pause  
  14.     set /p=%%i <nul
  15. )
复制代码
请问这里or里面的字母是怎么随机提出来的啊?还有set “_!random!!random!!random!=%%i"是怎么回事啊???
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2
活着就是为了改变世界

没人知道么??怎么没人理我啊?
活着就是为了改变世界

TOP

请问这里or里面的字母是怎么随机提出来的啊?

请问哪里有一个or?

TOP

还有set “_!random!!random!!random!=%%i"是怎么回事啊???

给一个变量赋值
变量的值是%%i
变量的名字是由一个下划线和三个随机数组成的字符串

TOP

回复 4# BAT-VBS

然后怎么把字母搞出来呢??
还有,下面的for里面的 ‘_set’怎么理解呢???望大神指点
活着就是为了改变世界

TOP

回复  BAT-VBS

然后怎么把字母搞出来呢??
还有,下面的for里面的 ‘_set’怎么理解呢???望大神指 ...
林小七 发表于 2013-4-24 13:29



打错了,不好意识,是set_
活着就是为了改变世界

TOP

回复 6# 林小七


看看帮助:
SET command invoked with just a variable name, no equal sign or value
will display the value of all variables whose prefix matches the name
given to the SET command.  For example:

    SET P

would display all variables that begin with the letter 'P'

做个实验:
set _a=1
set _b=2
set _c=3
set _
1

评分人数

TOP

回复 7# BAT-VBS


    懂了,谢谢啊,原来是一个临时的变量的集合.......学习了,以前知道在cmd里输入set m就输出m开头的环境变量,没想到还能这么用,高手啊,学无止境啊,还要努力啊
活着就是为了改变世界

TOP

返回列表