以下的例子,涉及对字典的键值的判断,以及根据字典键值对键的打印。
x = "googlel" y = "" for s in x: y = y + s usedChar = {} for t in y: if t not in usedChar: usedChar[t] = 1 else: usedChar[t] +=1 # print(usedChar) if 1 in usedChar.values(): a = list(usedChar.keys())[list(usedChar.values()).index(1)] print(a)