如何读取数据文件吗? [英] How to read data file?

查看:129
本文介绍了如何读取数据文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有数据 file.txt的,我想通过使用命令从中读取数据到变量:设置

If I have data file.txt and I want to read data from it into variable by using the command : set

如何才能做到这一点?

我怎样才能移动一行到另一个?

How can I do that?
How can I move one line to another?

推荐答案

从文件中读取两行,根据您的意见:

Read two lines from a file, based on your comments:

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (file.txt) do (
set /a N+=1
set v!N!=%%a
)

set sn=!v1!
set s=!v2!

您可能要考虑使用脚本语言,如果要处理多行。

You may want to consider using a scripting language, if you want to process multiple lines.

这篇关于如何读取数据文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆