您可以使用以下内容:a =', my city is changing . The country is changing . 'b =', my city is changing . The country is changing . 'print([(i, t) for i, t in enumerate(zip(a, b)) if t[0] != t[1]])这将打印[(21, ('\xa0', ' ')), (23, ('\xa0', ' '))]这会为每个字符串中的每个字符创建一个二元组列表,并打印不匹配字符的索引。