python 忽视大小写 以及 判断一个字符串是否是另一个的子串

判断一个字符串是否是另一个的子串:

>>> 'welcome' in 'WELCOME to'
False
>>> 'welcome' in 'welcome to'
True

忽视大小写,这里将字符串全部转成小写'WELCOME'.lower()

>>> 'welcome' in 'WELCOME to'
False
>>> 'WELCOME to'.lower()
'welcome to'
>>> 'welcome'.lower() in 'WELCOME to'.lower()
True
发布了74 篇原创文章 · 获赞 30 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/MustImproved/article/details/104759866