Generate QR Code using qrcode in Python Last Updated : 28 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report A Quick Response Code or a QR Code is a two-dimensional bar code used for its fast readability and comparatively large storage capacity. It consists of black squares arranged in a square grid on a white background.Python has a library "qrcode" for generating QR code images. It can be installed using pip.pip install qrcodeApproach:Import moduleCreate Qrcode with qrcode.make() and it returns a PilImage object.Save into imageSyntax:qrcode.make('Data to be encoded')Example 1: Python # Importing library import qrcode # Data to be encoded data = 'QR Code using make() function' # Encoding data using make() function img = qrcode.make(data) # Saving as an image file img.save('MyQRCode1.png') Output:Example 2:We can also use QRCode class to create a QR Code and change its details. It takes the following parameters:Version: This parameter is an integer from 1 to 40 that controls the size of the QR Code (the smallest, version 1, is a 21x21 matrix).error_correction: This parameter controls the error correction used for the QR Code. There are following four constants available for this :qrcode.constants.ERROR_CORRECT_L : About 7% or fewer errors can be corrected.qrcode.constants.ERROR_CORRECT_M (default) : About 15% or fewer errors can be corrected.qrcode.constants.ERROR_CORRECT_Q: About 25% or fewer errors can be corrected.qrcode.constants.ERROR_CORRECT_H: About 30% or fewer errors can be corrected.box_size: This parameter controls how many pixels each “box” of the QR code is.border: The border parameter controls how many boxes thick the border should be (the default is 4, which is the minimum in the specification).add_data(): Thismethod isused to add data to the QRCode object. It takes the data to be encoded as a parameter.make(): This method with (fit=True) ensures that the entire dimension of the QR Code is utilized, even if our input data could fit into less number of boxes.make_image(): Thismethod is used to convert the QRCode object into an image file. It takes the fill_color and back_color optional parameters to set the foreground and background color.Below is the implementation: Python # Importing library import qrcode # Data to encode data = "GeeksforGeeks" # Creating an instance of QRCode class qr = qrcode.QRCode(version = 1, box_size = 10, border = 5) # Adding data to the instance 'qr' qr.add_data(data) qr.make(fit = True) img = qr.make_image(fill_color = 'red', back_color = 'white') img.save('MyQRCode2.png') Output : How to Create QR Code Generator in Python? Comment More infoAdvertise with us Next Article Reading and Generating QR codes in Python using QRtools P piyushtiwari515 Follow Improve Article Tags : Python python-utility Practice Tags : python Similar Reads Reading and Generating QR codes in Python using QRtools This article aims to introduce the use of the python library: qrtools. This library can be used to both read QR codes and generate them. What are QR codes? QR code, or quick response code, is a trademark for a type of 2 dimensional barcode. 2 dimensional barcodes are similar to one dimensional barco 5 min read Wi-Fi QR Code Generator Using Python Prerequisite: Getting Saved Wifi Passwords using Python We know the wireless network is the most common network adapter for today, Because of its supports portability and User friendly. In this article, we will see how we can get the current saved Wi-Fi name and passwords and generate QR code to con 2 min read Python | Generate QR Code using pyqrcode module Let's see how to generate QR code in Python using pyqrcode module. pyqrcode module is a QR code generator. The module automates most of the building process for creating QR codes. This module attempts to follow the QR code standard as closely as possible. The terminology and the encodings used in py 2 min read Create Random RGB Color Code using Python Color codes are the defacto method of representing a color. It helps accurately represent the color, regardless of the display calibration. This article will teach you how to create random RGB color code using Python. RGB Color Code An RGB color code is a tuple containing 3 numbers representing Red, 3 min read Create a Random Password Generator using Python In this article, we will see how to create a random password generator using Python. Passwords are a means by which a user proves that they are authorized to use a device. It is important that passwords must be long and complex. It should contain at least more than ten characters with a combination 5 min read Python | Message Encode-Decode using Tkinter Prerequisite : Basics of TkinterPython offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and eas 5 min read Like