Image To Base64 Conversion In Python

Python provides several modules to work with images and encode them in base64 format. One of the most commonly used modules is the Pillow module, an updated version of the Python Imaging Library .To convert an image to base64 format in Python. import base64 def img_to_bs64(image_path): with open(img_path, “rb”) as img_file: return base64.b64encode(img_file.read()).decode(‘utf-8’) img_path = …

Image To Base64 Conversion In Python Read More »

Python Lambda Functions with Examples

Python Lambda Function python lambda function is similar to def keyword where def keyword is used to define a normal function in python and lambda keyword is used to define an anonymous function in python. Lambda function is used whenever function objects are required. Lambda functions are syntactically restricted to  single expression. It is mainly …

Python Lambda Functions with Examples Read More »

How to connect SQL Database in Python

Connecting MYSQL Database in python: To create the connection between mysql and python we use the connect() method of mysql.connector. To create connection we follow 5 steps in which we pass the database details like hostname ,username and password in the method calland then retruns the connection. The Steps are: STEP-1 :Download and installing the MYSQL …

How to connect SQL Database in Python Read More »

Collection in Python with examples

In python, collections are the containers used for storing the data. The built-in data structures in python are tuples, lists, sets and dictionaries. The collections class will provide additional data structures apart from the built-in data structures. Some of the data structures in the ‘collections’ module − Counter Named tuple ordered   from collections import …

Collection in Python with examples Read More »

Scroll to Top