英文:
how do i get echo to type out a % in a batch file
问题
我想要下面的代码生效或者有类似的效果。
@echo off
echo 100%
pause
当你打开.bat文件时,它应该显示如下。
100%
按任意键继续. . .
所以我希望`echo`输出百分比符号(%),而不是成为代码的一部分。
我希望它的效果与以下示例相同。
@echo off
echo hi
pause
我只尝试了`echo 100%`,因为我是编程新手,不知道还能尝试什么。
英文:
I want the code below to work or something that does the same thing.
@echo off
echo 100%
pause
When you open the .bat file it shuld look like this.
100%
Press any key to continue . . .
So i want the echo
to read out the % and not to be a part of a code.
I want it to work the same as for example
@echo off
echo hi
pause
I have only tried echo 100%
because i am a noob at coding so i dont know what else to try.
答案1
得分: 1
百分号在(Windows)批处理文件中具有特殊含义,用于指示变量。例如,echo %username%
将打印 username
变量的内容。
要回显字面上的 %
符号,您需要将其加倍,即 echo 100%%
。
英文:
The percent sign has special meaning in (Windows) batch files, it is used to indicate a variable. For instance, echo %username%
will print the contents of the username
variable.
To echo a literal %
sign, you need to double it, i.e. echo 100%%
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论