Board logo

标题: [文本处理] [已解决]批处理怎么随机提取的字母啊? [打印本页]

作者: 林小七    时间: 2013-4-20 18:51     标题: [已解决]批处理怎么随机提取的字母啊?

  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"是怎么回事啊???
作者: 林小七    时间: 2013-4-21 12:34

没人知道么??怎么没人理我啊?
作者: BAT-VBS    时间: 2013-4-22 18:20

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

请问哪里有一个or?
作者: BAT-VBS    时间: 2013-4-22 18:21

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

给一个变量赋值
变量的值是%%i
变量的名字是由一个下划线和三个随机数组成的字符串
作者: 林小七    时间: 2013-4-24 13:29

回复 4# BAT-VBS

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

回复  BAT-VBS

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



打错了,不好意识,是set_
作者: BAT-VBS    时间: 2013-4-24 16:30

回复 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 _
作者: 林小七    时间: 2013-4-24 23:06

回复 7# BAT-VBS


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




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2