In the tutorial on Basic Data Types in Python, you learned how to define strings: objects that contain sequences of character data. Processing character data is integral to programming. It is a rare application that doesn’t need to manipulate strings at least to some extent. Show
Here’s what you’ll learn in this tutorial: Python provides a rich set of operators, functions, and methods for working with strings. When you are finished with this tutorial, you will know how to access and extract portions of strings, and also be familiar with the methods that are available to manipulate and modify string data. You will also be introduced to two other Python objects used to represent raw byte data, the 29 and 30 types.Take the Quiz: Test your knowledge with our interactive “Python Strings and Character Data” quiz. Upon completion you will receive a score so you can track your learning progress over time: Take the Quiz » String ManipulationThe sections below highlight the operators, methods, and functions that are available for working with strings. Remove adsString OperatorsYou have already seen the operators 31 and 32 applied to numeric operands in the tutorial on Operators and Expressions in Python. These two operators can be applied to strings as well.The >>> s = 'foo.'
>>> s * 4
'foo.foo.foo.foo.'
>>> 4 * s
'foo.foo.foo.foo.'
|