In Python, strings can be enclosed in single quotes ('), double quotes ("), triple single quotes ('''), or triple double quotes ("""). Here are examples of each:
-
Single quotes:
single_quoted_string = 'Hello, World!' -
Double quotes:
double_quoted_string = "Hello, World!" -
Triple single quotes (often used for multi-line strings):
triple_single_quoted_string = '''This is a multi-line string.''' -
Triple double quotes (also used for multi-line strings):
triple_double_quoted_string = """This is another multi-line string."""
You can use either single or double quotes interchangeably, but if your string contains a quote character, you may want to use the other type to avoid escaping.
