Python

Python: How to Convert a String to Character Codes

Updated: June 1, 2023 By: Khue

Char codes, or character codes, are numbers that represent graphical characters, such as letters, digits, symbols, and punctuation marks. They allow characters to be stored, transmitted, and manipulated…

Python: 2 ways to remove multiple consecutive whitespaces

Updated: June 1, 2023 By: Khue

Multiple consecutive spaces in a string are spaces that occur more than once in a row, one follows another in a continuous series. They can make the string…

Python: 3 ways to convert a string to a URL slug

Updated: May 31, 2023 By: Khue

This concise, practical article will show you 3 different ways to turn a string into a URL slug in Python. Overview In the context of web development, a…

Python: Converting a string to bytes and vice versa

Updated: June 1, 2023 By: Khue

This concise example-based article shows you how to convert a string to bytes and vice versa in Python. Converting a string to bytes To turn a given string…

Working with the str.replace() method in Python

Updated: June 1, 2023 By: Khue

Syntax and Parameters The str.replace() method in Python is used to replace occurrences of a specified substring within a string with another substring. It was added to the…

Python: Remove non-alphanumeric characters from a string

Updated: June 1, 2023 By: Khue

Overview Non-alphanumeric characters are characters that are not letters or numbers. They include punctuation marks, symbols, whitespace, and control characters. For example, some of the non-alphanumeric characters are:…

Python: 4 Ways to Remove Substrings from a String

Updated: May 31, 2023 By: Khue

This concise, example-based article will walk you through several approaches to removing one or many substrings from a given string in Python. No time to waste; let’s get…

Python: 3 Ways to Validate Phone Numbers

Updated: May 31, 2023 By: Khue

Using the phonenumbers library (recommended) The most convenient and reliable way to validate a phone number in Python is to use the phonenumbers library. It can handle various…

Python: 3 Ways to Validate an Email Address

Updated: May 28, 2023 By: Khue

Using a regular expression The steps are: The regular expression pattern we will use to validate email addresses is: Code example: Output: Regular expressions provide a flexible and…

Python: 4 Ways to Generate Random Color Codes

Updated: May 28, 2023 By: Wolf

Color codes are numeric or alphanumeric representations that define specific colors. They are widely used in various fields, including web development, AI image generators, and data visualization. This…

1 56 57 58 59 60 64