我想搜索字符串中的一些字符,然后将它们保存在变量中,但以字符串中的写入方式保存。例如:
text = "this is a Long text"
searchinput = "a long"
if searchinput.lower() in text.lower():
print(searchinput)
输出当然是“a long”,但我希望输出与文本变量中的输出完全相同,即“a Long”。
简而言之:检查字符串是否在较长字符串中,然后检索长字符串版本。我怎样才能做到这一点?
烙印99
眼眸繁星
相关分类