fork download
  1. #Python字符串操作
  2. msg = "hello 123 WORLD"
  3. #输出字符串的总长度,并输出其中小写字母的个数
  4. length = len(msg)
  5. print("字符串的总长度:",length)
  6.  
  7. sum_msg = sum(1 for ch in msg if ch.islower())
  8. print("输出其中小写字母的个数:",sum_msg)
Success #stdin #stdout 0.07s 14116KB
stdin
Standard input is empty
stdout
字符串的总长度: 15
输出其中小写字母的个数: 5