Discuss / Python / 人生苦短,我用Python

人生苦短,我用Python

Topic source

hcie_zpc

#1 Created at ... [Delete] [Delete and Lock User]
    y = len(s)
    if y == 0:
        return s
    a = ' '
    x = 0
    while s[x] == a:
        x += 1
        if(x == y):
            break
    if x == y:
       return ''
    y -= 1
    while s[y] == a and y >= 0:
        y -= 1
    return s[x:y+1]

  • 1

Reply