题目: 代码:自己写的,不错 class Solution: def canConstruct(self, ransomNote: str, magazine: str) -> bool: c = set(ransomNote) for c1 in c: if ransomNote.count(c1)>magazine.count(c1): return False return True 1.set,直接提取字符串中的元索去重。 2.字符串的count函数。