Discuss / Python / 非独立思考的作业

非独立思考的作业

Topic source

    while s[:1] == ' ':

        s = s[1:]

    while s[-1:] == ' ':

        s = s[:-1]

    return s

111桦

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

厉害了,万万没想到能写怎么简

牛逼啊,这个写法真的好赞

冷月苍空

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

要是有两个空格就要出错了

冷月苍空

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

看错了,原来是带循环的,这个写法简单,就是每次都开辟新的内存空间存s


  • 1

Reply