快捷导航

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'''...'''还有什么意义?

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员2

防转义的,通常用于正则
回复

使用道具 举报

r的作用是把\n就只识别为\n而不是换行符
回复

使用道具 举报

可能感兴趣的问答

发新帖
TA的信息
  • 会员所属: 注册会员
  • 认证信息: 邮箱认证手机认证
  • 微信访问
  • 手机APP