题解 | #字符个数统计#
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
def count_char(str): string = ''.join(set(str)) #利用set无序不重复的性质,去重 count = 0 #计数器 for s in string: #遍历去重后的字符 if 0<= ord(s) <=127: #如果字符满足ASCII码的范围要求,则计数 count += 1 return count #函数返回计数的结果 str = input() print(count_char(str))