擅长:python、mysql、java
<p>首先,我认为理解分裂语法会对我们有所帮助。你知道吗</p>
<p>你知道吗文本.拆分(sep,max):(sep和max都是可选的)</p>
<p>sep:分隔文本的方式(默认为空格)</p>
<p>max:要拆分的最大组数(默认值为-1,表示所有组)</p>
<hr/>
<p>你的情况是这样的:</p>
<pre><code> text = "let the blue sky meet the blue sea"
## short answer
print(' '.join(text.split()[2:4]))
</code></pre>
<p>解释</p>
<p>我们将做三个步骤</p>
<pre><code># split it by default
list_word = text.split() # return ['let', 'the', 'blue', 'sky', 'meet', 'the', 'blue', 'sea']
# then we choose from 3rd to 4th elements
target_word = list_word[2:4] # return ['blue', 'sky']
# connect all element together with space
result = ' '.join(target_word)
print(result)
</code></pre>