in this example:
>>> 'DevNet' + 'Rocks'
'DevNetRocks'
Multiplication works as well, as in this example:
Click here to view code image
>>> 'DevNet Rocks ' * 5
'DevNet Rocks DevNet Rocks DevNet Rocks DevNet
Rocks DevNet Rocks '
There is a tremendous amount of string manipulation
you can do with Python, and there are a number of built-
in methods in the standard string library. These methods
are called with a dot after the variable name for a string.
Table 3-5 lists some commonly used string manipulation
methods, including the syntax used for each and what
each method does.
Table 3-5 String Methods
MethodWhat It Does
str.capitalize() Capitalize the string
str.center(width
[, fillchar])
Center justify the string
str.endwith(suffi
x[, start[, end]])
Add an ending string to the string
str.find(sub[,
start[, end]])
Find the index position of the
characters in a string
str.lstrip([chars]
)
Remove whitespace characters from
the end of the string