将GET参数添加到URL的语法是什么? [英] What is the syntax for adding a GET parameter to a URL?
问题描述
我使用 Python 和 Google App Engine 。
我需要通过向url添加一些元素来访问特定的网页。
添加GET参数到URL的语法是什么?
c $ c>?在url结尾。在?
之后,您将 var1 = val1& var2 = val2& ...
。
例如,如果您的原始网址(不带get参数)是 http://www.example.com/ ,你有两个参数, param1 = 7
和 param2 = seven
,那么完整的网址应该是:
http://www.example.com/?param1=7¶m2=seven 。
如果您想要在python中生成 param1 = 7& param2 = seven
,您可以使用参数字典,如下所示:
import urllib
parameters = urllib.urlencode({'param1':'7','param2':'seven'})
'param1 = 7& param2 = seven '
,所以你可以附加参数
字符串到这样的网址:
raw_url ='http://www.example.com/'
url = raw_url +'?'+ params
没有w url
的值是'http://www.example.com/?param1=7¶m2=seven'
。
I am using Python and Google App Engine.
I need to get access to certain webpage by adding some elements to the url.
What is the syntax for adding a GET parameter to a URL?
You put ?
in the end of the url. After the ?
you put var1=val1&var2=val2& ...
.
For example, if your raw url (without the get parameters) is http://www.example.com/ and you have two parameters, param1=7
and param2=seven
, then the full url should be:
http://www.example.com/?param1=7¶m2=seven.
If you want to generate the param1=7¶m2=seven
in python, you can use a parameter dictionary, like this:
import urllib
parameters = urllib.urlencode({'param1':'7', 'param2':'seven'})
The value of parameters
is 'param1=7¶m2=seven'
so you can append the parameters
string to a url like this:
raw_url = 'http://www.example.com/'
url = raw_url + '?' + params
Now the value of url
is 'http://www.example.com/?param1=7¶m2=seven'
.
这篇关于将GET参数添加到URL的语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!