Python Strings
Python has built-in support for strings and all of the common string manipulation actions.
Concatenation
Strings can be concatenated with the + operator.
Repetition
Indexing
Slicing
The slicing of strings can be easily done by using array-like syntax on a string object.
Find The Length
To find the length of a Python string, use the len()
function as shown below:
To get the amount of memory (in bytes) used to store a string, use the getsizeof()
function from sys:
Note that the number of bytes assigned to store the string may be much larger than the number of characters (even if they are single byte chars!) in the string itself.