Today, in a lot of computations we have to deal with text. For example whenever we prepare a document like a report, business presentation etc., we are manipulating text, searching for something or replacing and so on. We use text documents for import/export for manipulation of data.
Also, most of us manipulate queries when searching for something on the internet.
The ease of manipulating text is one of the reasons for the popularity of python.
Python uses an important sequence for text,i.e. Strings(class ‘str’).
What are the Strings?
In simple words,strings are consecutive sequence of characters enclosed(or surrounded) by single(‘ ‘),double(” “)or triple(‘” “‘)quotes.
Sequence of characters may include numbers, letters and special characters.
Double quotes and single quotes are the same in python.
- It is important to note that python does not support a character type. They are treated as strings of length one.
- Triple quotes are used for strings that span multiple lines. They are used when we have to process a file generally.
- Python treats quotes as special characters. To use them either we have to enclose the string in different type of quote or to use an escape sequence(\ character indicate special nature of a character.
- We can also use (\t) to tabulate the output.