python中反斜杠是什么意思


本文摘自php中文网,作者尚,侵删。

1、python本身使用\来转义一些特殊字符,比如在字符串中加入引号的时候

1

2

s = 'i\'m superman'

print(s)    # i'm superman

2、Python中反斜杠也可以用在一行结尾做续行符使用。

例:

1

2

3

4

5

6

hello = "This is a rather long string containing\n\

several lines of text just as you would do in C.\n\

    Note that whitespace at the beginning of the line is\

 significant."

   

print(hello)

注意,其中的换行符仍然要使用 \n 表示——反斜杠后的换行符被丢弃了。以上例子将如下输出:

1

2

3

This is a rather long string containing

several lines of text just as you would do in C.

    Note that whitespace at the beginning of the line is significant.

Python中的转义字符:

1.jpg

更多Python相关技术文章,请访问Python教程栏目进行学习!

以上就是python中反斜杠是什么意思的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python安装后怎么不见了

Python开发tornado网站之异步与协程化的介绍

Python列表中函数&方法详解

Python字典之中len方法是什么?len方法有什么作用?

append在Python里是什么

内存中数据序列化实例

如何使用ikanalyzer分词器自定义扩展词典

怎么下载安装Python64位

Python的数据结构

Python可以根据值寻找键吗

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...