def sed(filename, change_dict):
 f = open(filename, 'r')
 data = f.read()
 f.close()
 for (key, val) in change_dict.items():
  data = data.replace(key, val)
 f = open(filename, 'w')
 f.write(data)
 f.close()

def sed ( filename , change_dict ) : f = open ( filename , 'r' ) data = f . read ( ) f . close ( ) for ( key , val ) in change_dict . items ( ) : data = data . replace ( key , val ) f = open ( filename , 'w' ) f . write ( data ) f . close ( )
update file replacing key with value in provided dictionary .