Python

Money and Business

Measure processing time with Python’s timeit module.

Using the timeit module of the Python standard library, you can easily measure the execution time of a process in your c...
Money and Business

Get the quotient and remainder of a division at the same time using Python’s divmod

In Python, you can use "\" to calculate the quotient of an integer and "%" to calculate the remainder (remainder, mod).q...
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...
Copied title and URL