Share your link with a QR code using Python

Data Overload
3 min readNov 20, 2022

--

QR codes have been used in many different areas recently. I bet you saw one on a ticket to a game or a concert, or a conference/networking event you attended on the posters. A QR code is used in many areas such as marketing, security, academia, etc.

This story was written with the assistance of an AI writing program.

The number of smartphone users increases at any time, and so does the popularity of QR codes. More people are becoming aware of this technology and using it daily.

This image was created using an AI image creation program.

QR codes are a new and effective way of sharing your links. The old-fashioned way was directly typing the link, for example, I could share my instagram post link on a leaflet like https://www.instagram.com/p/ClMTvKvj6gG/?igshid=YmMyMTA2M2Y=. But a QR code is a better way since it is simpler for the audience to reach the link and visually more appealing.

For those unfamiliar with QR codes, you can scan a QR code with your mobile phone’s camera. You should open the camera application and direct it toward the QR code. Before shooting a photo, you will realize a link appears at the bottom of the QR code. Click that link and ta-daa! You can access the link the QR code is generated for.

So, I am going to show you how you can generate your QR code in Python. It is very short and simple. You can use QR codes to increase traffic to your website or social media account.

We need to install two libraries. You should install those libraries using some commands or manually, depending on where you compile your python code.

import qrcode
from PIL import Image

The next step is getting your link. You can copy it directly from the address bar. For example, I copied my profile link from medium and defined it as a variable named mylink. Please change the text between the inverted commas (‘’) to any other link that you like.

mylink = 'https://medium.com/@data-overload'

The text you have as mylink does not have to be a link, it can be a word, too. In this case, the code will lead to the default search engine and search for those words.

Now, this is where we generate a QR code for our link.

image = qrcode.make(mylink)

And finally, we use the below code to save our QR code. You can change the format simply by changing the extension. For .png format, use the code below.

image.save('myqrcode.png')

If you want to have a .jpeg file instead, you can use the code below.

image.save('myqrcode.jpeg')

Now, you can print your QR code anywhere you like and share your work! Here’s the QR code of my Medium profile!

In this article, we generated a QR code for your link.

If you like this post, check out my post below!

If you found this article useful, please give it a clap and share it with others.

Thank you!

--

--

Data Overload

Data Science | Finance | Python | Econometrics | Sports Analytics | Lifelong Learner