本文介绍了在 Python 中获取当前 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用 Python 获取当前 URL,
How would i get the current URL with Python,
我需要获取当前的 URL,以便我可以检查它的查询字符串,例如
I need to grab the current URL so i can check it for query strings e.g
requested_url = "URL_HERE" url = urlparse(requested_url) if url[4]: params = dict([part.split('=') for part in url[4].split('&')])这也在 Google App Engine 中运行
also this is running in Google App Engine
推荐答案试试这个:
self.request.url此外,如果您只需要查询字符串,这将起作用:
Also, if you just need the querystring, this will work:
self.request.query_string最后,如果您知道要查找的查询字符串变量,您可以这样做:
And, lastly, if you know the querystring variable that you're looking for, you can do this:
self.request.get("name-of-querystring-variable")更多推荐
在 Python 中获取当前 URL
发布评论