我已经创建了这段代码,当我在username
和yearsoflife
中键入要在.txt file
中导出的文本时,我无法这样做。
@echo off
color 0a
echo.
echo.
echo Please insert the following
echo.
echo.
echo.
set /p username=name:
set /p yearsoflife=age:
%username% > name.txt
%yearsoflife% > yourage.txt
答案 0 :(得分:0)
这是一种可能的解决方案:
@echo off
color 0a
echo.
echo.
echo Please insert the following
echo.
echo.
echo.
set /p _username=name:
set /p yearsoflife=age:
(echo=%_username%) > name.txt
(echo=%yearsoflife%) > yourage.txt
您的问题不清楚。您提到要在一个文本文件中同时包含两个变量内容。因此,您可以尝试(将>
符号加倍):
@echo off
color 0a
echo.
echo.
echo Please insert the following
echo.
echo.
echo.
set /p _username=name:
set /p yearsoflife=age:
(echo=%_username%) >> your_name.txt
(echo=%yearsoflife%) >> your_name.txt
注意:更改set /p username=name:
行只是为了不将此username
变量与username
环境变量混淆!