Wednesday, June 22, 2022

Python - String methods

There are a bunch of string methods listed over at W3Schools.
Here are some I particularly like:

count()    - Returns the number of times a specified value occurs in a string
find()    - Searches the string for a specified value and returns the position of where it was found
index()    - Searches the string for a specified value and returns the position of where it was found
isalnum()    - Returns True if all characters in the string are alphanumeric
isalpha()    - Returns True if all characters in the string are in the alphabet
isdecimal()    - Returns True if all characters in the string are decimals
isdigit()    - Returns True if all characters in the string are digits
isnumer()    - Returns True if all characters in the string are numeric
isprintable()    - Returns True if all characters in the string are printable
lstrip()    - Returns a left trim version of the string
replace()    - Returns a string where a specified value is replaced with a specified value
rfind()    - Searches the string for a specified value and returns the last position of where it was found
rindex()    - Searches the string for a specified value and returns the last position of where it was found
rstrip()    - Returns a right trim version of the string
split()    - Splits the string at the specified separator, and returns a list
startswith()    - Returns true if the string starts with the specified value
strip()    - Returns a trimmed version of the string
zfill()    - Fills the string with a specified number of 0 values at the beginning