题解 | #参数解析#

参数解析

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

while True:
    try:
        s = input().strip()
        len_s = len(s)
        lst = []
        cmd_lst = []
        count = 1

        for i in s:
            # print(i)
            if i == " " and '"' not in lst:
                if lst:
                    cmd_lst.append("".join(str(x) for x in lst))
                lst.clear()
            elif i == '"' and '"' in lst:
                if lst:
                    cmd_lst.append("".join(str(x) for x in lst[1:]))
                lst.clear()
            else:
                lst.append(i)
        if lst:
            cmd_lst.append("".join(str(x) for x in lst))
        print(len(cmd_lst))
        for x in cmd_lst:
            print(x)
    except:
        break

全部评论

相关推荐

码农索隆:这种hr,建议全中国推广
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
今天 13:15
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务