fork download
  1. msg="hello 123 WORLD"
  2. #统计长度和小写字母个数
  3. length=len(msg)
  4. lower_count=sum(1 for ch in msg if ch. islower())
  5. print("长度:",length)
  6. print("小写字母个数:",lower_count)
  7. #替换并转小写
  8. new_msg=msg.replace("WORLD","Python")
  9. result=new_msg.lower()
  10. print("结果:",result)
Success #stdin #stdout 0.02s 9108KB
stdin
Standard input is empty
stdout
长度: 15
小写字母个数: 5
结果: hello 123 python