How to sort list of dictionary by value python

Introduction Consider we have a Python list that contains 3 dictionaries: [{'name':'John', 'age':20}, {'name':'Bob', 'age':15}, {'name':'Charles', 'age':30}] When sorted by name, should become: [{'name':'Bob', 'age':15}, {'name':'Charles', 'age':30}, {'name':'John', 'age':20}] Using sorted funciton with lambda original_list = [{ 'name': 'John', 'age': 20 }, { 'name': 'Bob', 'age': 15 }, { 'name': 'Charles', 'age': 30 }] newlist = sorted(original_list, key=lambda k: k['name']) print(newlist) Output: [{'name': 'Bob', 'age': 15}, {'name': 'Charles', 'age': 30}, {'name': 'John', 'age': 20}] If sort using age: [Read more]

Receive and Send Gmail Using Python

In this tutorial, I will show a simple way to receive and send email using Python. Receive email using imaplib Python imaplib.IMAP4 class implements the actual IMAP4 protocol. The connection is created and protocol version (IMAP4 or IMAP4rev1) is determined when the instance is initialized. If host is not specified, “ (the localhost) is used. If port is omitted, the standard IMAP4 port (143) is used import email import imaplib import sys from email. [Read more]

Numpy quick start

Before You Begin notification Note Make sure you installed NumPy in your system, if not, please take a look at Install scipy The Basics NumPy’s main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In NumPy dimensions are called axes. For example, the coordinates of a point in 3D space [1, 2, 1] has one axis. [Read more]

Install SciPy

There are some ways to install SciPy. This guide will show you how to install SciPy on Windows, Linux and macOS platform. Scientific Python distributions The easiest way to install SciPy is download the coressponding install bundle one of these below distribution. Mose of them support Windows, Linux and macOS Anaconda: The Most Popular Python Data Science Distribution. There are distributions for Windows, Linux and macOS, chose one that match your system. [Read more]