廖雪峰老师的Python作业

xiaoxiao2022-06-11  26

 

关于廖雪峰老师Python学习网站上的作业

题目:利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法: def trim(s): if s==’’: return s if s[0]’ ': return trim(s[1:]) elif s[-1]’ ': return trim(s[:-1]) else: return s

第一次写博客 本人是Python小白。

转载请注明原文地址: https://www.6miu.com/read-4931741.html

最新回复(0)