> For the complete documentation index, see [llms.txt](https://cai-sen-se.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cai-sen-se.gitbook.io/leetcode/1001-2000/1816.-jie-duan-ju-zi.md).

# 1816.截断句子

[原题](https://leetcode-cn.com/problems/truncate-sentence/)

直接按空格切分，然后取前k个

```python
class Solution:
    def truncateSentence(self, s: str, k: int) -> str:
        strs = s.split(' ')
        return ' '.join(strs[:k])
```
