久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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)計(jì)字符串中數(shù)字個(gè)數(shù)

      python統(tǒng)計(jì)字符串中數(shù)字個(gè)數(shù)

      python統(tǒng)計(jì)字符串中數(shù)字個(gè)數(shù)的方法:

      ①定義數(shù)字、字母和其他類型字符初始個(gè)數(shù)為0

      ②遍歷字符串,判斷字符串內(nèi)各字符的類型,并分別累加

      ③輸出結(jié)果

      實(shí)現(xiàn)代碼:

      數(shù)字初始個(gè)數(shù)

      int_count = 0

      輸入字符串

      a = input(‘please input a strn’)

      遍歷字符串統(tǒng)計(jì)數(shù)字個(gè)數(shù):

      for i in a: # 判斷是否為數(shù)字 if i.isdigit(): int_count += 1  print(‘?dāng)?shù)字 = %d, ’ %( int_count ))

      Python isdigit() 方法檢測字符串是否只由數(shù)字組成。

      語法

      isdigit()方法語法:

      str.isdigit()

      返回值

      如果字符串只包含數(shù)字則返回 True 否則返回 False。

      python學(xué)習(xí)網(wǎng),免費(fèi)的在線學(xué)習(xí)python平臺(tái),歡迎關(guān)注!

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