Strings II
#!/usr/bin/python3
# Strings have various escapes.
print("Hi\nth\ere,\thow \141\x72\145\x20you?")
# Raw strings ignore them.
print(r"Hi\nth\ere,\thow \141\x72\145\x20you?")
print()
# Very useful when building file paths on Windows.
badpath = 'C:\that\new\stuff.txt';
print(badpath)
path = r'C:\that\new\stuff.txt';
print(path)
Lutz and Ascher list the escape charaters on p. 77.
The numeric and \x escapes are ASCII codes in octal and
hexadecimal, respectively.
If the escape is unknown, the backslash is retained, unlike C.
There is also a u qualifier to build Unicode strings.