温馨提示×

Python怎么去除字符串两端的空格

小亿
83
2024-03-02 14:41:09
栏目: 编程语言

在Python中,可以使用strip()方法去除字符串两端的空格。示例如下:

s = "   hello world   "
s_stripped = s.strip()
print(s_stripped)

输出结果为:

hello world

0