python 切片slice

实现php中trim函数,去掉字符串收尾的空格php

def trim(s):函数

    if s[0:1] != '' and s[-1:] != '':字符串

        return stest

    elif s[0:1] != '':im

        return trim(s[1:])字符

    else:return

        return trim(s[:-1])

print(trim('   jyl test   ')

相关文章
相关标签/搜索