码迷,mamicode.com
首页 > 其他好文 > 详细

chr ord 去重

时间:2019-11-27 23:39:57      阅读:73      评论:0      收藏:0      [点我收藏+]

标签:color   func   span   style   字母   一个   col   +=   相同   

找不同
字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母。

请找出在 t 中被添加的字母。

 

def func(s, t):
    num1 = 0
    num2 = 0
    for i in s:
        num1+= ord(i)
    for j in t:
        num2 += ord(j)
    return chr(num2-num1) # 这样写的好处在于:可以找到相同的字母,如‘abcc‘和‘abc‘

 

chr ord 去重

标签:color   func   span   style   字母   一个   col   +=   相同   

原文地址:https://www.cnblogs.com/su-sir/p/11946094.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!