本文摘自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中的转义字符:

更多Python相关技术文章,请访问Python教程栏目进行学习!
以上就是python中反斜杠是什么意思的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
归纳与总结一:requests的使用
Python中的对象属性如何访问?两种方法实例解析
Python能做什么?是什么意思?
pandas.dataframe中pivot()如何实现行转列的问题(代码)
孩子学Python有用吗
Python界面是什么样的
如何安装Python3
Python怎么打包apk
Python人工智能难吗
Python自带的编译器怎么打开
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python中反斜杠是什么意思