# 想输出带引号的字符串,可以用单引号或双引号将字符串包裹
str1 = '请对我说:"i like you"'
print(str1)
str2 = "请对我说:'i like you'"
print(str2)
# python不支持单字符类型,单字符在python中也是作为一个字符串
str3 = "A"
str4 = 'A'
print(str3)
print(str4)
# 用三个单引号或双引号可以使字符串内容保持原样输出,就不用使用转义了
str5 = """
The cat's stayed \nwell out of range of the children().
"""
print(str5)
# 字符串前面加上r可以使整个字符串不会被转义
str6 = r"\n\rdfsafa"
print(str6)
"""
输出结果:
请对我说:"i like you"
请对我说:'i like you'
A
A
The cat's stayed
well out of range of the children().
\n\rdfsafa
"""