比较Python中的字符串:字符串X是ASCII,字符串Y是UTF

2024-06-01 01:57:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个很奇怪的问题: 如何比较字符串(使用Python),其中字符串X是ASCII,字符串Y是UTF或Unicode?在

当前,当我比较字符串时,我收到以下问题:

UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  filteredtext = [t for t in s if t.lower() not in stopwords]

如何确保字符串的格式相同?在

谨致问候。在


Tags: to字符串inconvertasciiunicodeequalarguments