将GET参数添加到URL的语法是什么? [英] What is the syntax for adding a GET parameter to a URL?

查看:180
本文介绍了将GET参数添加到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&param2=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&param2=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&param2=seven.

If you want to generate the param1=7&param2=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&param2=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&param2=seven'.

这篇关于将GET参数添加到URL的语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆