题解 | #参数解析#

参数解析

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

while True:
    try:
        order=input()
        order=order.replace('"',',.') '''将引号换成,.'''
        order=order.split(',') '''用逗号分隔,同时留下.分辨'''
        a=[]
        for i in order:
            if "." not in i: '''非引号中命令'''
                tmp=i.split()
                for j in tmp:
                    a.append(j)
            elif "." in i: 
                if len(i)>1 and i[1]==" ":引号下一个命令
                    tmp=i[2:].split()
                    for j in tmp:
                        a.append(j)
                elif len(i)>1 and i[1]!=" ":引号中命令
                    a.append(i[1:])
        print(len(a))      
        for i in a:
            print(i)
    except:
        break

全部评论

相关推荐

10-15 20:01
已编辑
上海大学 Java
钉钉什么垃圾公司,约面鸽人
Syca_:途虎养车给我定了我这边早上六点的笔试,睡了四个小时起来难受的要命,告诉我面试时间是两天后的凌晨四点
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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