How-to articles, tricks, and solutions about PYTHON
How to stop/terminate a python script from running?
There are several ways to stop a Python script from running:
How to subtract a day from a date?
You can use the datetime module in Python to subtract a day from a date.
How to uninstall Python 2.7 on a Mac OS X 10.6.4?
To uninstall Python 2.7 on a Mac OS X 10.6.4, you can use the following commands in the terminal:
How to urlencode a querystring in Python?
You can use the urllib.parse.urlencode() function to urlencode a querystring in Python.
How to use glob() to find files recursively?
You can use the glob.glob() function from the glob module to search for files recursively.
I'm getting Key error in python
A KeyError in Python is raised when a dictionary key is not found in the dictionary.
if else in a list comprehension
Here's an example of using an if-else statement within a list comprehension:
if/else in a list comprehension
Here is an example of using an if/else statement in a list comprehension in Python:
Import error: No module name urllib2
It looks like you are trying to import the urllib2 module, which is not available in Python 3.
ImportError: No module named PIL
Here is a code snippet that demonstrates how to catch the "ImportError: No module named PIL" error:
ImportError: No module named pip
Here is a code snippet that demonstrates how to handle the "No module named pip" error: