如何在列表中测试子字符串
我需要检查列表中的字符串是否在my_list
中。
my_list = ['word1,word2,word3', 'g1,g2', 'word1']
当我在my_list 中运行'word2'时,它会返回false而不是true。
如何测试列表中的子字符串?
I need to check if a string is in the list my_list
.
my_list = ['word1,word2,word3', 'g1,g2', 'word1']
When I run 'word2' in my_list
, it returns False instead of True.
How can I test for substrings in the list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须检查字符串是否是每个列表的一部分 element 。
这样的事情:
You have to check whether your string is part of each list element.
Something like this: