如何从网址获取特定的路径部分?例如,我想要一个对此进行操作的函数:
http://www.mydomain.com/hithere?image=2934
Run Code Online (Sandbox Code Playgroud)
并返回"hithere"
或对此进行操作:
http://www.mydomain.com/hithere/something/else
Run Code Online (Sandbox Code Playgroud)
并返回相同的东西("hithere")
我知道这可能会使用urllib或urllib2,但我无法从文档中找出如何仅获取路径的一部分.