Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Built in String Methods Python

The document lists various built-in string methods in Python, detailing their functionalities such as converting cases, checking character types, and manipulating string content. Each method is briefly described, including operations like capitalize(), count(), find(), and split(). This serves as a reference for developers to utilize string methods effectively in their Python programming.

Uploaded by

Vedansh Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Built in String Methods Python

The document lists various built-in string methods in Python, detailing their functionalities such as converting cases, checking character types, and manipulating string content. Each method is briefly described, including operations like capitalize(), count(), find(), and split(). This serves as a reference for developers to utilize string methods effectively in their Python programming.

Uploaded by

Vedansh Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Built-in String Methods in Python

capitalize() - Converts the first character to uppercase.

casefold() - Converts the string to lowercase, more aggressive than lower().

center(width[, fillchar]) - Centers the string, padding it with specified character.

count(sub[, start[, end]]) - Returns the number of non-overlapping occurrences of a substring.

encode(encoding='utf-8', errors='strict') - Encodes the string using the specified encoding.

endswith(suffix[, start[, end]]) - Checks if the string ends with the specified suffix.

expandtabs(tabsize=8) - Replaces tabs with spaces, using the specified tabsize.

find(sub[, start[, end]]) - Returns the lowest index of the substring, or -1 if not found.

format(*args, **kwargs) - Performs string formatting.

format_map(mapping) - Formats the string using a dictionary mapping.

index(sub[, start[, end]]) - Returns the lowest index of the substring, raises ValueError if not found.

isalnum() - Checks if all characters are alphanumeric.

isalpha() - Checks if all characters are alphabetic.

isascii() - Checks if all characters are ASCII characters.

isdecimal() - Checks if all characters are decimals.

isdigit() - Checks if all characters are digits.

isidentifier() - Checks if the string is a valid Python identifier.

islower() - Checks if all characters are lowercase.

isnumeric() - Checks if all characters are numeric.

isprintable() - Checks if all characters are printable.

isspace() - Checks if all characters are whitespace.

istitle() - Checks if the string follows title case rules.

isupper() - Checks if all characters are uppercase.

join(iterable) - Joins elements of an iterable with the string as a separator.

ljust(width[, fillchar]) - Left-justifies the string, padding it with specified character.


lower() - Converts all characters to lowercase.

lstrip([chars]) - Removes leading characters (default is whitespace).

maketrans(x[, y[, z]]) - Creates a translation table for use with translate().

partition(sep) - Splits the string into a 3-tuple around the first occurrence of sep.

replace(old, new[, count]) - Replaces occurrences of a substring with another substring.

rfind(sub[, start[, end]]) - Returns the highest index of the substring, or -1 if not found.

rindex(sub[, start[, end]]) - Returns the highest index of the substring, raises ValueError if not found.

rjust(width[, fillchar]) - Right-justifies the string, padding it with specified character.

rpartition(sep) - Splits the string into a 3-tuple around the last occurrence of sep.

rsplit(sep=None, maxsplit=-1) - Splits the string from the right, optionally limiting the splits.

rstrip([chars]) - Removes trailing characters (default is whitespace).

split(sep=None, maxsplit=-1) - Splits the string into a list using the specified separator.

splitlines([keepends]) - Splits the string at line breaks.

startswith(prefix[, start[, end]]) - Checks if the string starts with the specified prefix.

strip([chars]) - Removes leading and trailing characters (default is whitespace).

swapcase() - Swaps the case of all characters.

title() - Converts the string to title case.

translate(table) - Translates the string using a translation table.

upper() - Converts all characters to uppercase.

zfill(width) - Pads the string with zeros on the left to reach the specified width.

You might also like