Discuss / Python / qiepian

qiepian

Topic source

regnaro

#1 Created at ... [Delete] [Delete and Lock User]

def trim(s):

if not s:

return s

if s[0] == ' ':

s = trim(s[1:])

elif s[-1] == ' ':

s = trim(s[:-1])

return s

香菜假面

#2 Created at ... [Delete] [Delete and Lock User]

def trim(s):

    if not len(s)>1:

        print("字符过短")

    if s[0] == ' ':

        s = s[1:]

    if s[-1] == ' ':

        s =s[:-1]

        return s

a=trim(" time ")

print(a)


  • 1

Reply