我有2个字符串
a = "abc feat. def"
b = "abc Feat. def"
我想要获取单词feat.
或Feat.
之前的字符串。
这是我正在做的事情,a.split("feat.", 1)[0].rstrip()
这将返回abc
。但如何使用分隔符进行不区分大小写的搜索呢?
这是我到目前为止尝试过的:
b.split("feat." or "Feat.", 1)[0].rstrip()
输出 - abc Feat. def
b.split("feat." and "Feat.", 1)[0].rstrip()
输出 - abc
a.split("feat." and "Feat.", 1)[0].rstrip()
输出 - abc feat. def
。
a.split("feat." or "Feat.", 1)[0].rstrip()
输出 - abc
为什么在这两种情况下使用and
和or
会有不同的结果?