Python 字符串包含判断:使用 'in' 运算符
在 Python 中,可以使用 'in' 运算符来判断一个字符串是否包含另一个字符串。
例如:
string1 = 'Hello, World!'
string2 = 'Hello'
if string2 in string1:
print('string1包含string2')
else:
print('string1不包含string2')
输出结果是:string1包含string2
原文地址: https://www.cveoy.top/t/topic/qz3S 著作权归作者所有。请勿转载和采集!