2.3.2 字符串

单引号 双引号 三引号 都可
在Python中字符串属于不可变序列
区别:
单引号和双引号字符序列必须在同一行
三引号可以多行

eg:
title = '我喜欢的名言警句'
mot_cn = "命运给予我们的不是失望之酒,而是希望之杯."
mot_en = '''Our destiny offers not the cup of despai,
but the chance of opportunity'''
print(title)
print(mot_cn)
print(mot_en)

在字符串定界符引号的前面加字母r/R,那么该字符将原样输出

print("失望之酒\x0a机会之杯")
失望之酒
机会之杯
print(r"失望之酒\x0a机会之杯")
失望之酒\x0a机会之杯

posted @ 2020-12-23 18:49  菜鸟本鸟gyh  阅读(35)  评论(0)    收藏  举报