In this section, we will look at strings in detail.
As we mentioned in the previous chapter, strings are a sequence of characters. The characters in a string can be enclosed in either single (') or double (") quotes. This does not make a difference. A string enclosed in single quotes is completely identical to one enclosed in double quotes:
>>> "a string" 'a string' >>> 'foobar' 'foobar' >>>
A double-quoted string can contain single quotes:
>>> "Susan's" "Susan's" >>>
A single-quoted string can also contain double quotes:
>>> '"Help!", he exclaimed.' '"Help!", he exclaimed.' >>>
You can also build a multiline string by enclosing the characters in triple quotes (''' or """):
>>> s = """A multiline string""" >>> print(s) A multiline string >>> s2 = '''Also a multiline string ''' >>> print(s2) Also a multiline string >>>
Also, as you saw in the first chapter...