如何确定子字符串是否在不同的字符串中 [英] How to determine whether a substring is in a different string
本文介绍了如何确定子字符串是否在不同的字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个子字符串:
substring = "请帮帮我"
我还有一个字符串:
string = "请帮我解决这个问题"
如何使用 Python 确定 substring
是否是 string
的子集?
解决方案
with in
: substring in string
:
I have a sub-string:
substring = "please help me out"
I have another string:
string = "please help me out so that I could solve this"
How do I find if substring
is a subset of string
using Python?
解决方案
with in
: substring in string
:
>>> substring = "please help me out"
>>> string = "please help me out so that I could solve this"
>>> substring in string
True
这篇关于如何确定子字符串是否在不同的字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文