标签:== def 空格 body pre trim 处理 turn class
要求去除字符串首尾的空格。
def trim(s): while s[:1] == ‘ ‘: s = s[1:] while s[-1:] == ‘ ‘: s = s[:-1] return s
[Python] 使用切片处理字符串
原文地址:https://www.cnblogs.com/immjc/p/8410765.html