题解 | #参数解析#

参数解析

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

import sys

while True:
    try:
        a= input().split(' ')
        n = len(a)
        cnt =0
        b=''
        c=[]
        start='"'
        end ='"'
        flag =True
        for i in range(n):
            if flag:
                if a[i].startswith(end) and not a[i].endswith(start):
                    flag = not flag
                    b+=a[i]
                else:
                    c.append(a[i])
                    cnt+=1
            else:
                if not a[i].startswith(start) and a[i].endswith(end):
                    flag = not flag
                    b+=' '+a[i]
                    c.append(b)
                    cnt+=1
                else:
                    b =b+' '+a[i]
        print(str(cnt))
        for i in c:
            print(i.strip('"'))      
    except:
        break

全部评论

相关推荐

05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务