gpt4 book ai didi

windows - 回显到 .txt 后删除尾随空格

转载 作者:可可西里 更新时间:2023-11-01 10:02:47 26 4
gpt4 key购买 nike

这是我当前的 .bat:

set /p lastname=Please enter last name: 
set /p firstname=Please enter first name:
set /p sex=Please enter sex:
set /p age=Please enter age:
set /p weight=Please enter weight (kg):
set /p location=Please enter location:
set /p admitdate=Please enter admit date:
mkdir %lastname%%firstname:~0,1%
cd %lastname%%firstname:~0,1%
echo|set /p=%lastname%>lastname.txt
echo|set /p=%firstname%>firstname.txt
echo|set /p=%age%>age.txt
echo|set /p=%sex%>sex.txt
echo|set /p=%weight%>weight.txt
echo|set /p=%location%>location.txt
echo|set /p=%admitdate%>admitdate.txt

我正在尝试将这些变量中的每一个写入它们自己的 .txt。当我回应 .txt 时,我很难摆脱尾随的空格。例如,如果 lastname 是 Smith,则 lastname.txt 显示为 Smith_,其中 _ 表示空格。

我目前所做的尝试包括:

  • 删除变量和 carat 之间的空格:%firstname% > firstname.txt%firstname%>firstname.txt
  • 切换回显和输出文件的顺序:>firstname.txt echo|set/p=%firstname%。这只会让每个 .txt 都说 Echo is ON

这些方法都没有奏效。供您引用,我还试图摆脱尾随 echo\n。到目前为止,我已经通过使用 echo|set\p 实现了这一点。

最佳答案

这个结构对我有用:

@set firstname=John
@<nul >firstname.txt set /p=%firstname%

关于windows - 回显到 .txt 后删除尾随空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49141027/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com