Python: How to Algin a String (Left, Right, and Center)
This pithy tutorial will show you a couple of different ways to align left, align right, or center a string in Python. Text width & length Before getting…
Python: Get Hostname and Protocol from a URL
This concise article shows you how to get the hostname and the protocol from a given URL in Python. Before writing code, let me clarify some things. Suppose…
Python: 3 Ways to Get File Name and Extension from URL
Suppose you have a file URL like this: Or like this: How can you programmatically extract the file name (with or without extension) and the file extension from…
Python: 3 ways to extract all URLs from text
This succinct practical article will show you a couple of different ways to extract all URLs from a given string in Python. These techniques might be helpful in…
Python: 3 Ways to Check If a String Is a Valid URL
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…
Python: 3 Ways to Add Leading Zeros to a String
In Python programming, adding leading zeros (zeros left-padding) to a string is useful in various scenarios, such as when maintaining consistent formatting, sorting values, or ensuring proper alignment…
How to base64 encode/decode a string in Python
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…
Python: Convert character to Unicode code point and vice versa
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…
2 ways to get the size of a string in Python (in bytes)
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…
Python: 3 Ways to Convert a String to Binary Codes
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…