python中反斜杠是什么意思(Python中关于反斜杠)
生活随笔
收集整理的這篇文章主要介紹了
python中反斜杠是什么意思(Python中关于反斜杠)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、python本身使用\來轉義一些特殊字符,比如在字符串中加入引號的時候
s = 'i\'m superman' print(s) # i'm superman
登錄后復制
2、Python中反斜杠也可以用在一行結尾做續行符使用。
例:
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 表示——反斜杠后的換行符被丟棄了。以上例子將如下輸出:
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中反斜杠是什么意思的詳細內容,更多請關注風君子博客其它相關文章!
總結
以上是生活随笔為你收集整理的python中反斜杠是什么意思(Python中关于反斜杠)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 这4种钱没有也要借,不能等
- 下一篇: ps钢笔工具怎么抠图