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://...“
页面和等号之间没有空格哇,太疯狂了!我没意识到空格很重要!