在Python中,我想读取输入,然后只在某个点之后打印。我希望它像这样工作
humaninput = raw_input("Please enter:")
breakdown = humaninput.split()
say = "say"
if say in breakdown:
print (all words after say)
除了最后一部分,我什么都有了
最佳答案
这是一个不使用 split
的简洁替代方案。
string = "string blah say foo bar"
say = "say"
after = string[string.index(say) + len(say):] # +1 if you're worried about spaces
print(after)
>> foo bar
如果有多个“say”实例,它将采用第一个。
关于python - 在Python中的某个单词后打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24814063/