题解 | #字符个数统计#【熟悉方法:ASCII与字符转换】

字符个数统计

https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50

import sys

x = input()

y = x[0]
for i in range(1, len(x)):
    if x[i] not in y and ord(x[i]) >= 0 and ord(x[i]) <= 127:
        y = y + x[i]
    else:
        pass

print(len(y))

【目的】

python中用于将字符转换为ASCII的方法为:ord();

python中用于将ASCII转换为字符的方法为:char()。

全部评论

相关推荐

叁六玖:有阿里妈妈,那有不有阿里爸爸
求职遇到的搞笑事件
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务