How do I extract emails from dictionary in python as key value pair? -


from following dictionary structure, how extract , print email addresses? e.g. want see 'smauel.david@gmail' 4, 'sdusa@yahoo.com' 1, etc.

dict_items([('10:04:14', 1), ('3', 6), ('thu', 6), ('19:51:21', 1), ('2008',27),  ('from', 27), ('11:35:08', 1), ('5', 1), ('sntp@hotmail.com', 3), ('jan', 27), ('15:46:24', 1), ('14:50:18', 1),  ('11:37:30', 1), ('18:10:48', 1), ('17:07:00', 1), ('09:05:31', 1),  ('10:38:42', 1), ('sdusa@yahoo.com', 1), ('samuel.david@gmail.com', 4) ]) 

use dict comprehensions

d = dict([('10:04:14', 1), ('3', 6), ('thu', 6), ('19:51:21', 1),('2008',27),  ('from', 27), ('11:35:08', 1), ('5', 1),('sntp@hotmail.com', 3), ('jan', 27), ('15:46:24', 1), ('14:50:18',1),  ('11:37:30', 1), ('18:10:48', 1), ('17:07:00', 1), ('09:05:31',1),  ('10:38:42', 1), ('sdusa@yahoo.com', 1),('samuel.david@gmail.com', 4) ])  {email:val email, val in d.items() if '@' in email } 

output:

 {'sdusa@yahoo.com': 1, 'samuel.david@gmail.com': 4, 'sntp@hotmail.com': 3} 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -