题解 | #参数解析#

参数解析

http://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677



def op(s):
    option = ''
    while s:
        if s[0] != '"':
            if s[0] != ' ':
                option += s[0]
                s = s[1:]
            else:
                if option:
                    res.append(option)
                s = s[1:]
                return op(s)
        else:
            s = s[1:]
            while s[0] != '"':
                option += s[0]
                s = s[1:]
            else:
                res.append(option)
                s = s[1:]
                return op(s)
    else:
        if option:
            res.append(option)
        return res


while True:
    try:
        s1 = input()
        s2 = op(s1)
        print(len(s2))
        for i in s2:
            print(i)
    except:
        break
全部评论

相关推荐

投递拼多多等公司10个岗位 Java求职圈
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务