无法搜索给定字符串中的特定子字符串

时间:2017-05-18 09:27:09

标签: python string substring

str_search = "DD09"

str_1 = "DD09 High speed status"
Str_2 = "Dd09 High speed status"

str.find (str_search)
print(str)

输出:DD09高速状态

为什么无法打印Str_2?我如何克服这个问题?

1 个答案:

答案 0 :(得分:1)

在搜索前将两个字符串设为小写:

str_search = "DD09"

str_1 = "DD09 High speed status"
Str_2 = "Dd09 High speed status"

position = Str_2.lower().find(str_search.lower())
print(position)