python 字符个数统计

地址:

https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50?tpId=37&tqId=21233&rp=1&ru=%2Fta%2Fhuawei&qru=%2Fta%2Fhuawei%2Fquestion-ranking&tab=answerKey

 1 '''
 2 题目描述
 3 编写一个函数,计算字符串中含有的不同字符的个数。字符在ACSII码范围内(0~127),换行表示结束符,不算在字符里。不在范围内的不作统计。多个相同的字符只计算一次
 4 例如,对于字符串abaca而言,有a、b、c三种不同的字符,因此输出3。
 5 输入描述:
 6 输入一行没有空格的字符串。
 7 
 8 输出描述:
 9 输出范围在(0~127)字符的个数。
10 
11 12 输入
13 abc
14 输出
15 3
16 '''
17 
18 n = input()
19 s = set(list(n))
20 print(len(s))
原文地址:https://www.cnblogs.com/whycai/p/14655372.html