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

lewis 2016-11-10 19次阅读

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

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

输出结果为:

hello world


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。