def save_tweets(filename, tweets):
 if (len(tweets) == 0):
  return
 try:
  archive = open(filename, 'w')
 except IOError as e:
  err(('Cannot save tweets: %s' % str(e)))
  return
 for k in sorted(tweets.keys()):
  try:
   archive.write(('%i %s\n' % (k, tweets[k].encode('utf-8'))))
  except Exception as ex:
   err(('archiving tweet %s failed due to %s' % (k, unicode(ex))))
 archive.close()

def save_tweets ( filename , tweets ) : if ( len ( tweets ) == 0 ) : return try : archive = open ( filename , 'w' ) except IOError as e : err ( ( 'Cannot save tweets: %s' % str ( e ) ) ) return for k in sorted ( tweets . keys ( ) ) : try : archive . write ( ( '%i %s\n' % ( k , tweets [ k ] . encode ( 'utf-8' ) ) ) ) except Exception as ex : err ( ( 'archiving tweet %s failed due to %s' % ( k , unicode ( ex ) ) ) ) archive . close ( )
save tweets from dict to file .