Python is a cross-platform computer programming language. It is an object-oriented dynamic type language. It was originally designed to write automated scripts (shell). With the continuous update of the version and the addition of new language features, it is increasingly used for the development of independent and large-scale projects.
Although python is a universal language that can be used to write any type of program, it is most commonly used to write the following applications
Scripts-These short programs automatically perform common management tasks, such as adding users to the system, uploading files to websites, downloading web pages without using a browser, etc.
Website development-As a tool for quickly creating dynamic websites, many python projects such as Django (www.djangoproject.com), Bottle (www.bottlepy.org) and Zope (www.zope.org) are very popular among developers. For example: the popular news website www.rebbit.com is developed using python.
Text processing-Python provides powerful support for string and text file processing, including regular expressions and Unicode.
Scientific computing-There are many excellent python scientific computing libraries on the Internet, which provide functions for statistics, mathematical calculations and graphing.
Education-In view of the simplicity and practicality of python, more and more schools use it as the first programming language of instruction.
Of course, python is not the best choice for any project. Its speed is usually slower than languages such as Java, C#, C++, etc., so python will not be used to develop new operating systems.
However, when you need to minimize the time the programmer spends on the project, python is usually the best choice.
Okay, now you are on the right track. First prepare the python portal: Click me to send
The tutorials for configuring environment variables are in the above portal
Secondly install pip in the computer
Win10 click on the start menu and enter cmd to run as an administrator
Win7 press win+r and enter cmd to run as an administrator
Open cmd and enter the following code:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Enter after downloading the Pip program
sudo python get-pip.py
After the installation is complete, cmd enters pip
to see if the installation is successful
Then enter in the cmd window
pip install removebg
Install the third-party package after the installation is complete
Go here remove.bg
Register with email and get API (free)
Recommend a development tool: pycharm Portal: Poke me
Finally, create a new project, create a .py file and copy the code
# Import the third-party RemoveBg package
from removebg import RemoveBg
import os
# Fill in the API parameters and error log file name in the calling method. Replace FJSLcn1KYKP4t3y5SiMmuSh3 with your own API
rmbg =RemoveBg("FJSLcn1KYKP4t3y5SiMmuSh3","./error.log")
# Specify the file output directory as the pic folder of the project directory
path = os.path.join(os.getcwd(),"pic")for pic in os.listdir(path):
# Export the processed pictures to the pic folder
rmbg.remove_background_from_img_file(os.path.join(path, pic))
You can quickly cut out the picture (processed within 5 seconds)
Outstanding effect
Recommended Posts