Last active
February 24, 2018 07:26
-
-
Save cecilialee/8c28512f128991827285ad4404e8aae9 to your computer and use it in GitHub Desktop.
Build x-callback-url in Python. #python #python2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import webbrowser | |
def build_url(app, action, action_parameter_dict): | |
url = '%s://x-callback-url/%s' % (app, action) | |
if action_parameter_dict: | |
par_list = [] | |
for k, v in action_parameter_dict.items(): | |
par_list.append( | |
k + '=' + urllib.quote(unicode(v).encode('utf8'))) | |
url = url + '?' + '&'.join(par_list) | |
return url | |
url = build_url('bear', 'open-note', {'title':'My note title'}) | |
webbrowser.open_new(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment