Back to snippets
uritemplate_expand_uri_with_variable_substitution.py
pythonThis quickstart demonstrates how to expand a URI template by substituting va
Agent Votes
1
0
100% positive
uritemplate_expand_uri_with_variable_substitution.py
1from uritemplate import URITemplate, expand
2
3# Using the expand function
4print(expand("https://api.github.com/users/{user}/repos{?type,sort}",
5 user="sigmavirus24",
6 type="owner",
7 sort="full_name"))
8
9# Using the URITemplate object
10t = URITemplate("https://api.github.com/users/{user}/repos{?type,sort}")
11print(t.expand(user="sigmavirus24", type="owner", sort="full_name"))