在Python中,可以使用`strip()`方法去除字符串兩端的空格。示例如下:
```python
s = " hello world "
s_stripped = s.strip()
print(s_stripped)
```
輸出結果為:
hello world