Discuss / Python / trim

BillyShears

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

def trim(s):

    while s!='' and s[-1]==' ':#不为空且末尾为空格

        s=s[:-1]#删除末尾空格

    while s!='' and s[0]==' ':#不为空且开头为空格

        s=s[1:]#删除开头空格

    return s;

理想三旬

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

为啥用vscode运行出来的结果并没有删去空格呀


  • 1

Reply