自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Python String類型基本應(yīng)用情況分析

開發(fā) 后端
我們今天會通過對一段代碼示例的解讀來為大家詳細(xì)介紹一下有關(guān)Python String類型的相關(guān)操作方法,大家可以從中獲得更多的幫助。

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

Python String類型應(yīng)用代碼示例:

  1. >>> 'hello world'  
  2. 'hello world'  
  3. >>> "hello world"  
  4. 'hello world'  
  5. >>> "doesn't"  
  6. "doesn't"  
  7. >>> 'hello "tom"'  
  8. 'hello "tom"'  
  9. >>> "hello,\"tom\""  
  10. 'hello,"tom"'  
  11. >>> hello="hello,\  
  12. i miss you."  
  13. >>> print(hello)  
  14. hello,i miss you.  
  15. >>> print(r"hello\n world")  
  16. hello\n world  
  17. >>> word='hello'+'A'  
  18. >>> print(word)  
  19. helloA  
  20. >>> word[0:5]+'B'  
  21. 'helloB'  
  22. >>> word[-1]  
  23. 'A'  
  24. >>> len(word) 

注意:#t#

單引號''和雙引號""作用相同,都用來表示字符串,但是單引號''中可以有雙引號"",雙引號""中也可以有單引號'',但是如果雙引號""中使用雙引號""或是單引號''中使用單引號''時(shí),必須使用轉(zhuǎn)義字符\,例如\'或\"。

行末尾\表示字符串換行。

字符串前的r表示純字符串,此時(shí)字符串中的轉(zhuǎn)義字符失效。

+表示字符串的鏈接。

[]可以用來索引字符串中的字符,但是不能用來修改字符串中的字符。

len()用來獲得字符串的長度。

以上就是對Python String類型的相關(guān)介紹。

責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2010-02-23 18:10:01

WCF綁定類型

2010-03-03 14:30:05

Python set類

2013-12-12 16:10:21

Lua腳本語言

2010-03-01 18:11:40

WCF數(shù)據(jù)契約變更

2010-03-03 16:40:55

Python HTTP

2010-03-04 14:57:08

Python解密VBS

2010-03-03 10:03:55

Python連接Sql

2010-03-03 14:40:37

Python打包方法

2010-03-04 09:27:34

調(diào)用Python腳本

2010-07-08 15:24:17

SNMP trap

2010-03-03 16:08:26

Python取得文件列

2010-03-04 15:52:59

Python構(gòu)造列表

2017-11-30 18:42:22

PythonCPU腳本分析

2010-03-03 15:17:46

Python調(diào)用MyS

2010-02-04 17:16:33

C++調(diào)用python

2010-03-03 13:32:08

Python壓縮文件

2010-02-02 14:45:35

C++ typeof

2010-02-25 10:52:29

WCF響應(yīng)服務(wù)

2010-02-26 13:40:28

WCF消息頭

2010-02-23 15:58:57

WCF Session
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號