# urlopen try: from urllib2 import urlopen # Python 2 except ImportError as e: from urllib.request import urlopen # Python 3 # urlencode try: from urllib import urlencode # Python 2 except ImportError as e: from urllib.parse import urlencode # Python 3 # key, value dictionary iteration def iterdict(dictionary): if hasattr(dictionary, 'iteritems'): # Python 2 return dictionary.iteritems() else: # Python 3 return dictionary.items() # dict comprehention mydict = dict((key, value) for (key, value) in [row.split('=') for row in response]) # Python 2 and 3?? mydict = {key: value for (key, value) in [row.split('=') for row in response]} # Python 2.7 and 3
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question