题目:字符串中第一个只出现一次的字符。
def first_not_repeat(strs):
dic = {}
for s in strs:
if s not in dic:
dic[s] = 1
else:
dic[s] += 1
for k,v in dic.items():
if v==1:
return k
注:遍历两次字符串。第一次用字典统计各个字符出现的次数,第二次遍历输出value值为1的key。