题解 | #参数解析#

参数解析

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

import sys
for line in sys.stdin:
    a = list(line.strip().split(" "))
num,str1,just,relist = len(a),'',False,[]
for i in range(num):
    if a[i].count('"') == 1:
        just = not just
        if just:
            indexrecord=i
        else:
            relist.append(str1 + str(a[i]))
            str1 = ''
            continue
    if just:
        str1 += str(a[i])+' '
    else:
        relist.append(a[i])
print(len(relist))
for i in relist:
    if i.count('"') >=1:
        print(i[1:-1])
    else:
        print(i)

全部评论

相关推荐

10-02 19:29
已编辑
浙江科技大学 运营
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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