Python 签入字符串
Check In 签入字符串
要检查字符串中是否存在某个短语或字符,我们可以使用关键字 in
或 not in
.
实例
检查以下文本中是否存在短语 "ain":
txt = "The rain in Spain stays mainly in the plain"
x = "ain" in txt
print(x)
亲自试一试 »
实例
检查以下文本中是否不存在短语 "ain":
txt = "The rain in Spain stays mainly in the plain"
x = "ain"
not in txt
print(x)
亲自试一试 »