r'''...'''和'''...'''的区别?

我知道raw字符串的功能是自动转义,不需要使用\。可是这个语句:

print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
和去掉r之后的

print '''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''

结果是一样的,那么

①r'''...'''和'''...'''的区别是什么?

②感觉'''...'''自带自动转义功能,那么r'''...'''还有什么意义?

不斯文败类
浏览 1743回答 3
3回答

闭上眼就睡诶

防转义的,通常用于正则

慕粉9965376

r的作用是把\n就只识别为\n而不是换行符
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python