相关疑难解决方法(0)

在字符串中查找单词的位置

附:

sentence= input("Enter a sentence")
keyword= input("Input a keyword from the sentence")
Run Code Online (Sandbox Code Playgroud)

我想在句子中找到关键字的位置.到目前为止,我有这个代码摆脱标点符号并使所有字母小写:

punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''#This code defines punctuation
#This code removes the punctuation
no_punct = "" 
for char in sentence:
   if char not in punctuations:
       no_punct = no_punct + char

no_punct1 =(str.lower (no_punct)
Run Code Online (Sandbox Code Playgroud)

我知道需要一段实际找到该单词位置的代码.

python string find python-3.x

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

find ×1

python ×1

python-3.x ×1

string ×1