Appendix » String Methods »

 

String Methods

The following table provides a list of operators and methods defined for the Python string class. Since strings are immutable, none of the methods modify the string instance for which the method is invoked.

Method Usage Description
Operators
str() s = str( “Python” )
s = str( 4.5 )
The constructor creates a string from the given argument. Any value from the built-in types can be passed to the constructor. Python also allows users to overload the string constructor by defining a string conversion operator as part of a user-defined class.
+ t = s + “ is fun” String concatenation resulting in a new third string.
Methods
capitalize() s.capitalize()
© 2006 - 2008: Rance Necaise - Page last modified on September 15, 2006, at 03:57 PM