1. Use Python for Google search

Sometimes we are so invested in programming that we are too lazy to open the browser and search for our queries. But with the amazing python library google, we only need to write 3 lines of code to search for our query without having to manually open the browser and search for our query on it

Install

pip install google

Example

#import library
from googlesearch import search
#write your query
query = "best course for python"
# displaying 10 results from the search
for i in search(query, tld="co.in", num=10, stop=10, pause=2):
    print(i)
#you will notice the 10 search results(website links) in the output.

2. Extract audio from video files

In some cases, we have mp4 files, but we only need the audio in them. It's like making a video with the audio of another video. We tried to get the same audio file, but we failed. Unfortunately, we decided to choose another music file. This problem is solved with the python library moviepy, because we can extract audio from the video file through this

Install

pip install moviepy

Example

#import library
import moviepy.editor as mp
#specify the mp4 file here(mention the file path if it is in different directory)
clip = mp.VideoFileClip('video.mp4')
#specify the name for mp3 extracted
clip.audio.write_audiofile('Audio.mp3')
#you will notice mp3 file will be created at the specified location.

3. Short link

When you have to deal with long URLs on a regular basis, processing them is a busy task. The idea of ​​URL Shorteners (such as bit.ly and tinyurl) came up. These services shorten the URL to less than 50 characters. We can create our own URL shortener pyshorteners with the help of python library

Install

pip install pyshorteners

Example

#import library
import pyshorteners
#creating object
s=pyshorteners.Shortener()
#type the url
url = "type the youtube link here"
#print the shortend url
print(s.tinyurl.short(url))

4. Convert image to PDF

Sometimes we use notes or files as photos, and learning in this way becomes difficult. We may follow the wrong order and things will become messy and annoying. To solve this problem, one idea is to collect all the images and then convert them into a pdf file. This can be done with the python library img2pdf

Install

pip install img2pdf

Example

#import libraries
import os
import img2pdf
#specify the name for pdf file
with open("converted.pdf", "wb") as f:
    #collect all the images in a single folder and specify its location
    f.write(img2pdf.convert([i for i in os.listdir(files\images) if i.endswith(".jpg")]))

5. Plagiarism Detector

One of the most important factors in dealing with content writing is plagiarism. When the files are in the bundle, it is not even possible to check them manually. A plagiarism detector tool is required. We can also create our own plagiarism detector difflib with the help of the python library. It can be used to check the similarity between two or more files on the device

Install

pip install difflib

6. Translation

We live in a world of people who speak multiple languages. Therefore, to understand the other party’s language, we need a language translator because we cannot learn so many languages. We can create our own language translator Translator with the help of python library

Install

pip install translate

Example

#import the library
from translate import Translator
#specifying the language
translator = Translator(to_lang="Hindi")
#typing the message
translation = translator.translate('Hello!!! Welcome to my class')
#print the translated message
print(translation)

7. QR code generator

We often see QR (Quick Response) codes in our daily lives. A very simple example is a payment application, where a QR code saves users a lot of time. We can also use the python library to create our unique QR code qrcode for websites or personal data

Install

pip install qrcode

Example

#import the library
import qrcode
#link to the website
input_data = "https://car-price-prediction-project.herokuapp.com/"
#Creating object
#version: defines size of image from integer(1 to 40), box_size = size of each box in pixels, border = thickness of the border.
qr = qrcode.QRCode(version=1,box_size=10,border=5)
#add_date: pass the input text
qr.add_data(input_data)
#converting into image
qr.make(fit=True)
#specify the foreground and background color for the img
img = qr.make_image(fill='black', back_color='white')
#store the image
img.save('qrcode_img.png')
点赞(0)

评论列表 共有 0 评论

暂无评论

微信服务号

微信客服

淘宝店铺

support@elephdev.com

发表
评论
Go
顶部