They can be delimited by either single (
'
) or double ("
)
quotes in Python. Strings must be contained all on one line, except
when delimited by triple
quotes.Examples of string literals:
- ‘Hello’
- ‘Smith,
John’
- “Baltimore, Maryland 21210”
Strings may contain quote characters as long as different quotes are used to delimit the string. For example, “Jennifer Smith’s Friend”.
Python allows using more than one type of quote to handle
situations where quotes are part of the string. Conventionally, single quotes are
used for delimiting strings, and double
quotes are used when needed.