python中反斜杠是什么意思(Python中关于反斜杠)
生活随笔
收集整理的這篇文章主要介紹了
python中反斜杠是什么意思(Python中关于反斜杠)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、python本身使用\來(lái)轉(zhuǎn)義一些特殊字符,比如在字符串中加入引號(hào)的時(shí)候
s = 'i\'m superman' print(s) # i'm superman
登錄后復(fù)制
2、Python中反斜杠也可以用在一行結(jié)尾做續(xù)行符使用。
例:
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)
登錄后復(fù)制
注意,其中的換行符仍然要使用 \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.
登錄后復(fù)制
Python中的轉(zhuǎn)義字符:
更多Python相關(guān)技術(shù)文章,請(qǐng)?jiān)L問(wèn)Python教程欄目進(jìn)行學(xué)習(xí)!
以上就是python中反斜杠是什么意思的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注風(fēng)君子博客其它相關(guān)文章!
總結(jié)
以上是生活随笔為你收集整理的python中反斜杠是什么意思(Python中关于反斜杠)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 这4种钱没有也要借,不能等
- 下一篇: ps钢笔工具怎么抠图