新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
PythonString類型基本應用情況分析
Python String類型在實際應用中可以給我們帶來非常大的好處。在接下來的文章中,我們將會在這里為大家詳細介紹一下有關Python String類型的相關應用方式,希望大家可以充分的掌握這一應用。

創(chuàng)新互聯(lián)公司是專業(yè)的東陽網(wǎng)站建設公司,東陽接單;提供成都網(wǎng)站建設、網(wǎng)站建設,網(wǎng)頁設計,網(wǎng)站設計,建網(wǎng)站,PHP網(wǎng)站建設等專業(yè)做網(wǎng)站服務;采用PHP框架,可快速的進行東陽網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
Python String類型應用代碼示例:
- >>> '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#
單引號''和雙引號""作用相同,都用來表示字符串,但是單引號''中可以有雙引號"",雙引號""中也可以有單引號'',但是如果雙引號""中使用雙引號""或是單引號''中使用單引號''時,必須使用轉義字符\,例如\'或\"。
行末尾\表示字符串換行。
字符串前的r表示純字符串,此時字符串中的轉義字符失效。
+表示字符串的鏈接。
[]可以用來索引字符串中的字符,但是不能用來修改字符串中的字符。
len()用來獲得字符串的長度。
以上就是對Python String類型的相關介紹。
本文題目:PythonString類型基本應用情況分析
轉載來源:http://www.5511xx.com/article/dpcgihd.html


咨詢
建站咨詢
