Money and Business

Counting the number of occurrences of each element in a list with Python’s Counter

In Python, the number of all elements in a list or tuple can be obtained using the built-in function len(), and the numb...
Money and Business

Be careful when dealing with Boolean values in Python’s argparse

To handle command line arguments in Python, use the argv or argparse modules of the sys module.The argparse module allow...
Money and Business

List of string methods for manipulating uppercase and lowercase letters in Python

Python's string type (str) comes standard with convenient methods for manipulating uppercase and lowercase letters. ...
Money and Business

Writing long strings of text on multiple lines in Python

If you use a PEP8 compliant code checker such as flake8 in Python, you will get the following error when a line exceeds ...
Money and Business

Batch change a file name in Python by adding a string or sequential number before and after the file name

Rename in bulk using the os module and glob module.Use the os module and glob module to change and rename the file names...
Money and Business

Sorting a list in Python: the difference between sorted and sorted

There are two ways to sort a list in ascending or descending order in Python.sort()sorted()If you want to sort a string ...
Money and Business

Get a list of file and directory names in Python.

To get a list of file and directory names (folder names) in Python, use the os module function os.listdir().os.listdir(p...
Money and Business

Convert binary, octal, and hexadecimal numbers and strings to and from each other in Python

Python can handle numbers and strings as binary, octal, and hexadecimal numbers as well as the usual decimal numbers. It...
Money and Business

Be careful when reading a csv with a comma followed by a space in Python

In Python, you can easily read and write csv files using the standard csv module.csv — CSV File Reading and Writing — Py...
Money and Business

Create pip.conf and remove the pip list warning

I updated pip to 9.0.1 and now I get a warning message in the pip list command.DEPRECATION: The default format will swit...
Copied title and URL