13 Python Hidden Hacks You Probably Don’t Know About
Awesome Python hacks that you have probably never heard of
Python is famous because of the cool stuff it offers. In this article, I will show you the 13 Python hidden hacks you Probably never know. So without wasting any time let jump into it.
1. Run Web Server
Do you want to run your own web server and share files between PC and Phone then here is the snippet code that will run a web server on any port using Python? You can set the port from range 0 to 65353.
# Run Web Serverpython -m http.server 8000
Once you executed the above snippet code you will see this output. But on windows, the server is started on IP 127.0.0.1. So we can access our computer data from the web with the URL http://127.0.0.1:8000/.
#Server is Started
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
2. Trimming
The below Hack will help you to trim your garbage or full of unwanted special characters in a String. The below snippet uses a built-in method strip that I mostly used to cut down an unwanted special character mostly, newline, tabs and etc. This snippet comes in handy in web data extraction in which you…