Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 使用cmd时如何设置和获取变量_Variables_Batch File_Cmd - Fatal编程技术网

Variables 使用cmd时如何设置和获取变量

Variables 使用cmd时如何设置和获取变量,variables,batch-file,cmd,Variables,Batch File,Cmd,我正在cmd中使用cURL发送HTTP GET和POST请求 很多时候,我会把请求发送到同一个页面,每次都把它们打印出来是一件非常痛苦的事情 我正试图弄清楚如何使用set=,以便每次使用这些URL时都能保存它们 我试过了 C:\>set page = "http://www.mywebpage.com/api/user/friends" C:\>page 'page' is not recognized as an internal or external command, ope

我正在
cmd
中使用
cURL
发送HTTP GET和POST请求

很多时候,我会把请求发送到同一个页面,每次都把它们打印出来是一件非常痛苦的事情

我正试图弄清楚如何使用
set=
,以便每次使用这些URL时都能保存它们

我试过了

C:\>set page = "http://www.mywebpage.com/api/user/friends"

C:\>page
'page' is not recognized as an internal or external command,
operable program or batch file.

C:\>echo %page%
%page%
但它不会返回页面名称

我怎样才能完成我所需要的

C:\Windows\system32>set page="http://www.mywebpage.com/api/user/friends"

C:\Windows\system32>echo %page%
"http://www.mywebpage.com/api/user/friends"

C:\Windows\system32>set page=http://www.mywebpage.com/api/user/friends

C:\Windows\system32>echo %page%
http://www.mywebpage.com/api/user/friends
不要在
=
周围使用空格。根据需要选择带或不带
的版本。变量值中可能包含空格:

C:\Windows\system32>set page=http://www.mywebpage.com/api/user/my friends

C:\Windows\system32>echo %page%
http://www.mywebpage.com/api/user/my friends

您正在设置值
”http://www.mywebpage.com/api/user/friends“
在变量“page”(注意空格)内,因为=前面有空格


因此,您可以使用
%page%
或使用
设置页面=”来检索该值http://...“
页面和等号之间没有空格

哇,太疯狂了!我没意识到空格很重要!