久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      python統(tǒng)計不同字符的個數(shù)

      python統(tǒng)計不同字符的個數(shù)

      python統(tǒng)計不同字符的個數(shù)

      首先使用input獲取輸入數(shù)據(jù),并存入到str參數(shù)里

      然后使用for循環(huán)str的每一個字符,循環(huán)內(nèi)使用str.count()獲取字符出現(xiàn)的字數(shù),并存入一個字典中

      最后輸出字典即可。

      代碼如下:

      str = input("請輸入一串字符:") resoult = {} for i in str:     resoult[i] = str.count(i) print(resoult)

      效果如下:

      python統(tǒng)計不同字符的個數(shù)

      注:

      Python count() 方法用于統(tǒng)計字符串里某個字符出現(xiàn)的次數(shù)。可選參數(shù)為在字符串搜索的開始與結(jié)束位置。

      語法:

      str.count(sub, start= 0,end=len(string))

      眾多python培訓(xùn)視頻,盡在python學(xué)習網(wǎng),歡迎在線學(xué)習!

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號