新聞中心
Python String類型在實際應(yīng)用中可以給我們帶來非常大的好處。在接下來的文章中,我們將會在這里為大家詳細(xì)介紹一下有關(guān)Python String類型的相關(guān)應(yīng)用方式,希望大家可以充分的掌握這一應(yīng)用。

創(chuàng)新互聯(lián)公司是專業(yè)的東陽網(wǎng)站建設(shè)公司,東陽接單;提供成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè),網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行東陽網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!
Python String類型應(yīng)用代碼示例:
- >>> 'hello world'
- 'hello world'
- >>> "hello world"
- 'hello world'
- >>> "doesn't"
- "doesn't"
- >>> 'hello "tom"'
- 'hello "tom"'
- >>> "hello,\"tom\""
- 'hello,"tom"'
- >>> hello="hello,\
- i miss you."
- >>> print(hello)
- hello,i miss you.
- >>> print(r"hello\n world")
- hello\n world
- >>> word='hello'+'A'
- >>> print(word)
- helloA
- >>> word[0:5]+'B'
- 'helloB'
- >>> word[-1]
- 'A'
- >>> len(word)
注意:#t#
單引號''和雙引號""作用相同,都用來表示字符串,但是單引號''中可以有雙引號"",雙引號""中也可以有單引號'',但是如果雙引號""中使用雙引號""或是單引號''中使用單引號''時,必須使用轉(zhuǎn)義字符\,例如\'或\"。
行末尾\表示字符串換行。
字符串前的r表示純字符串,此時字符串中的轉(zhuǎn)義字符失效。
+表示字符串的鏈接。
[]可以用來索引字符串中的字符,但是不能用來修改字符串中的字符。
len()用來獲得字符串的長度。
以上就是對Python String類型的相關(guān)介紹。
網(wǎng)站標(biāo)題:PythonString類型基本應(yīng)用情況分析
網(wǎng)頁URL:http://m.5511xx.com/article/dpcgihd.html


咨詢
建站咨詢
