Strings

Strings in Ren'Py and Python are sequences of characters. Mostly they will be used for the text the player sees, but they can also be used for internal values like keys or attribute names.
See Python 3 Text sequence type: str 

String literals

There are three ways to mark the beginning and end of a string:

Single quotes
If you start with single quotes you can include double quotes freely inside the string. 'So I yelled "Stop!"'
Double quotes
If you start with double quotes you can include single quotes freely inside the string. This is useful for contractions such as "I didn't do it!"
Triple single/double quotes
If you start with three quotes of either type the string can easily go across multiple lines. In Python (but not Ren'Py script) double or single quotes can appear freely in the string, provided they are not the group of three that mark the end.

Escape sequences

Inside a string the \ character has a special meaning, "escaping" one or more characters that follow it. This allows whatever delimiter used to also be included in the string.
See String literals  , (Python 2) , and Ren'Py escape characters .

SequenceMeaning
\newline The backslash and newline are not included in the string. Allows the string to extend over multiple lines. Triple quoted strings provide a better way to do this as does string literal concatenation (Python). Not required in Ren'Py strings which can span multiple lines by default.
\space Ren'Py text only, produces a single space character that won't be stripped out.
\\A single \
\'A single '
\"A single "
\a The ASCII Bell character (BEL, 0x07). Has no function in Ren'Py text. When output to a terminal this causes an audible beep.
\b The ASCII Backspace character (BS, 0x07). Has no function in Ren'Py text.
\f The ASCII Form feed character (BS, 0x0c). Has no function in Ren'Py text.
\n The ASCII Line feed character (LF, 0x0a). Starts a new line in Ren'Py text.
\r The ASCII Carriage return character (CR, 0x0d). Has no function in Ren'Py text.
\t The ASCII Tab character (HT, 0x09). Has no function in Ren'Py text.
\v The ASCII Vertical tab character (VT, 0x0b). Has no function in Ren'Py text.
\ooo The character with the octal value given. There can be 1, 2, or 3 octal digits 0..7.
\N{name} The unicode character with the given name. The names are case-sensitive. For example:

    $ tmp = "\N{GREEK CAPITAL LETTER DELTA}"

Note: Ren'Py's Text displayables can't handle multicoloured fonts, so emoji symbols may not work. For these you have to use inline images.
See Unicode charts  for the official names. These aren't the same as the HTML entity names! NO-BREAK SPACE is the name of the entity  
\uxxxxThe unicode character with the 16bit hex value.
\UxxxxxxxxThe unicode character with the 32bit hex value.
\xhh The character with the hex value given. There should be 2 hex digits (unlike standard C). Either a..f or A..F can be used.
\% Ren'Py text only, produces a single percentage sign %.
%% Ren'Py text only, produces a single percentage sign %.
[[ Ren'Py text only, produces a single left square bracket [. Unescaped this starts Ren'Py text interpolation.
{{ Ren'Py text only, produces a single left curly bracket {. Unescaped this starts a Ren'Py text tag.
【【 Ren'Py text only, produces a single left lenticular bracket . Unescaped this starts Ren'Py ruby text.

String literal concatenation Python only

In Python if one string literal is followed by another then they are joined together at compile time, and treated as a single string. This provides another way to build a long string without an excessively long line of code. The example below creates a single string Hello world.


    $ tmp = "Hello" ' world.'

String prefixes

Python allows strings to be prefixed with one or more letters:

PrefixMeaning
b or B Creates a bytes sequence instead of a string.
f or F Python 3 only. Creates a formatted string literal that has Python text interpolation.
r or R Disables escape character \ processing, leaving the string as written.
u or U Creates a Unicode string. This is optional as Ren'Py automatically defaults to Unicode strings, as does Python 3. You may see strings prefixed with u in console output.
br, bR, Br, BR, rb, rB, Rb, RB Creates a bytes sequence instead of a string and disables escape character \ processing, leaving the string as written.
fr, fR, Fr, FR, rf, rF, Rf, RF Python 3 only. Creates a formatted string literal that has Python text interpolation and disables escape character \ processing, leaving the string otherwise as written.

Recommendation

Use double quoted text for strings that will be displayed to the player. Use single quoted text for strings that name attributes, labels, keys, key-word arguments.

Since the unicode escape sequence with named characters is particularly verbose it can be simpler to define "constants" for commonly used ones.