6.6. String Built-in Methods

String methods were recently added to Python, introduced in version 1.6 (and in JPython 1.1), and tweaked for 2.0. These methods are intended to replace most of the functionality in the string module as well as to bring new functionality to the table. Table 6.6 shows all the current methods for strings. All string methods should fully support Unicode strings. And some are applicable only to Unicode strings.

Table 6.6. String Type Built-in Methods
ValueDescription
string.capitalize()capitalizes first letter of string
string.center(width)returns a space-padded string with the original string centered to a total of width columns
string.count(str, beg= 0,end=len(string))counts how many times str occurs in string, or in a ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.