Python: 3 Ways to Check If a String Is a Valid URL
Updated: Jun 02, 2023
This concise example-based article will walk you through three different ways to check whether a string is a valid URL or not in Python. The first two approaches only use built-in features of Python, while the last one takes advantage of......
How to base64 encode/decode a string in Python
Updated: Jun 01, 2023
This succinct, practical article shows you how to base64 encode/decode a string in Python. Base64 encode a string Base64 encoding is a process of converting a string into a format that uses a set of 64 characters to represent binary......
Python: Convert character to Unicode code point and vice versa
Updated: Jun 01, 2023
This concise and straight-to-the-point article will show you how to convert a character to a Unicode code point and turn a Unicode code point into a character in Python. What are Unicode code points? A Unicode code point is a......
2 ways to get the size of a string in Python (in bytes)
Updated: Jun 01, 2023
This concise, straight-to-the-point article will show you 2 different ways to get the size (in bytes) of a string in Python. There’s no time to waste; let’s get started! Using the encode() method and the len()......
Python: Capitalize the First Letter of each Word in a String
Updated: Jun 01, 2023
This concise and straightforward article will show you four different ways to capitalize the first letter of each word in a given string in Python. Using the title() method (easiest approach) str.title() is a built-in method of......
Python: Converting a string to bytes and vice versa
Updated: Jun 01, 2023
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 into bytes, you can use either the bytes() function or the str.encode()......
Working with the str.replace() method in Python
Updated: Jun 01, 2023
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 language from the early days and still is one of the most......
Python: Remove non-alphanumeric characters from a string
Updated: Jun 01, 2023
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: 3 Ways to Convert a String to Binary Codes
Updated: Jun 01, 2023
Binary codes (binary, binary numbers, or binary literals) are a way of representing information using only two symbols: 0 and 1. They are like a secret language that computers are able to understand. By combining these symbols in......
Python: How to Convert a String to Character Codes
Updated: Jun 01, 2023
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 by digital computers. For instance,......
Python: 2 ways to remove multiple consecutive whitespaces
Updated: Jun 01, 2023
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 look uneven or messy. For instance, let’s have a glance at the string......
Python: 3 ways to convert a string to a URL slug
Updated: May 31, 2023
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 URL slug is the last part of a URL that serves as a unique identifier of the......