python中反斜杠的案例分析
导读:本文共660字符,通常情况下阅读需要2分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 1、python本身使用\来转义一些特殊字符,比如在字符串中加入引号的时候s = 'i\'m superman'print(s) # i'm superman2、Python中反斜杠也可以用在一行结尾做续行符使用。例:hello = "This is a rather long string containing... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。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 containingseveral lines of text just as you would do in C. Note that whitespace at the beginning of the line is significant.
Python中的转义字符:
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:
python中反斜杠的案例分析的详细内容,希望对您有所帮助,信息来源于网络。