日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python字符串在實際中的操作手冊

Python字符串在使用的時候是需要我們進行詳細的學習。下面我們就看看在具體的操作中如何才能更好的進行這個字符串的使用方法。在之后的使用中還是需要我們繼續(xù)學習。

昭化ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

 
 
 
  1. #coding:utf-8 
  2. #兩個小函數(shù)
  3. #一、查找字符在字符串中第一次出現(xiàn)的位置. 
  4. def find(string, char): 
  5. index = 0 
  6. while index < len(string): 
  7. if (string[index] == char): 
  8. return index 
  9. index += 11
  10. return -111 
  11. #二、查找字符在字符串中的總數(shù)
  12. def findSum(string, char):
  13. index = 0
  14. count = 0
  15. while index < len(string):
  16. if (string[index] == char):
  17. count += 1
  18. index += 1
  19. return count
  20. #使用以上兩個函數(shù)
  21. print "字符1在字符串1211211234中第一次出現(xiàn)的位置: ", find("1211
    211234", "1")
  22. print "字符1在字符串1211211234中出現(xiàn)的次數(shù):", findSum("1211211
    234", "1")
  23. import string #引入string庫
  24. print string.find('www.cctv.com', 'com') #result=9
  25.  print string.find('Good','d') #result = 3
  26. print string.find('canada', 'a',2,9) #result =3,用法如下:
  27. #string.find(s, sub[, start[, end]])函數(shù)說明
  28. #Return the lowest index in s where the substring sub is 
    found such that sub is
  29. #wholly contained in s[start:end]. Return -1 on failure. 
    Defaults for start and
  30. #end and interpretation of negative values is the same 
    as for slices.
  31. print string.lowercase #常量,abcdefghijklmnopqrstuvwxyz
  32. print string.uppercase #常量,ABCDEFGHIJKLMNOPQRSTUVWXYZ
  33. print string.digits #常量,012345678937 
  34. def isLower(char): #判斷一個字符是否為小寫
  35. if (string.find(string.lowercase, char) > -1):
  36. return 'Good'
  37. return 'bad'
  38. print isLower('S')
  39. def isLowertest(char): #另外一種判斷字符是否為小寫的方法
  40. return char in string.lowercase46 print isLowertest('a')

以上就是對Python字符串的相關介紹,希望大家有所收獲。


網(wǎng)頁名稱:Python字符串在實際中的操作手冊
網(wǎng)站路徑:http://www.dlmjj.cn/article/dhipjcd.html