Skip to main content

Python cheatsheet

Get content of URL
import urllib2
print urllib2.urlopen('http://google.com').read()
Remove chars and split by , from a string convert to list
'jshfjshfjsh[]'.translate(None, '[] "\n').split(',')
Diff between two arrays
set(['first', 'second', 'third']) - set(['first', 'second'])

Comments