久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長資訊網
      最全最豐富的資訊網站

      python統計字符串中數字個數

      python統計字符串中數字個數

      python統計字符串中數字個數的方法:

      ①定義數字、字母和其他類型字符初始個數為0

      ②遍歷字符串,判斷字符串內各字符的類型,并分別累加

      ③輸出結果

      實現代碼:

      數字初始個數

      int_count = 0

      輸入字符串

      a = input(‘please input a strn’)

      遍歷字符串統計數字個數:

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

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

      語法

      isdigit()方法語法:

      str.isdigit()

      返回值

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

      python學習網,免費的在線學習python平臺,歡迎關注!

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