5.统计字符串字符个数,空格字符个数,数字字符个数,其他字符个数 [python] view plain copyimport string s=input('please input string:')letters = 0 space = 0 digit = 0 others =0 for ch in s:if ch.isalpha():
import string s=input('please input string:') letters = 0 space = 0 digit = 0 others =0 for ch in s: if ***.isalpha(): letters += 1 elif ***.isspace(): space += 1 elif ***.isdigit(): digit += 1 else: others += 1 print(letters, space , digit,...
要记得返回len 值而不是返回这个列表。 该错误发生在如下代码中:spam = ['cat', 'dog', 'mouse'] for i in range(spam): print(spam[i])5)尝试修改string的值(导致“TypeError: 'str' object does not support item assignment”) string是一种不可变的数据类型,该错误发生在如下代码中: spam = 'I ...