newgain 当前离线
上等兵
评分人数
Gin_Q 当前离线
五级士官
@echo off SetLocal EnableDelayedExpansion set "dict=" for /f "tokens=1-2" %%L in ('type 1.txt') do ( set "dict%%L=%%M") set /p input="请输入序号" echo !dict%input%! pause复制代码
TOP
wxyz0001 当前离线
一级士官
with open('city.txt', 'r', encoding='gbk') as f: lines = f.readlines() city_dict = {line.split(' ')[0]: line.split(' ')[1].strip('\n') for line in lines if line.find(' ') != -1} while True: key = input('请输入城市的索引(输入0退出):') if key == '0': break print('索引对应的城市为:', city_dict[key])复制代码
qixiaobin0715 当前离线
大校
@echo off set /p var=请输入: for /f "tokens=1*" %%i in ('findstr /b /c:"%var% " test.txt') do echo,%%j pause复制代码
jonnywang 当前离线
列兵
@echo off&chcp 65001&color f0 set file=test.txt for /f "tokens=1-2" %%a in (%file%) do echo %%a %% ... jonnywang 发表于 2021-6-3 22:23
@echo off&chcp 65001&color f0 for /f "tokens=1-2" %%a in (test.txt) do echo %%a %%b>nul set /p in=输入对应的号码: for /f "tokens=1-2" %%a in (test.txt) do ( if "%in%"=="%%a" echo %%b ) pause复制代码
smss 当前离线
中尉
@Echo off&SetLocal EnableDelayedExpansion for %%i in (北京 天津 上海 武汉 苏州 沈阳南京 广州)do call set "T%%n%%=%%i"&set /a n+=1 choice /c:12345678 /m:"输入数字:" echo !T%errorlevel%! pause复制代码