题解 | 参数解析

def jiexi(s):
    # xcopy /s "C:\\program files" "d:\"
    res = []
    if '"' not in s:  # 如果不含"",可以直接按空格分割
        res = s.split(' ')
        return res
    else:          
        ls = s.split('"')   # 如果含"",按"分割肯定能分成3组,中间是引号内容
        if ls[0] == '':  # 排除"位于字符首位
            pass
        elif ' ' in ls[0]:  # 有空格继续按空格分割
            res.extend(ls[0].strip().split(' '))
        else:
            res.append(ls[0])
			
        res.append(ls[1])
		
        if ls[-1] == '':  # 排除"位于字符尾部
            pass
        elif ' ' in ls[-1]:  # 有空格继续按空格分割
            res.extend(ls[-1].strip().split(' '))
        else:
            res.append(ls[-1])
        return res
while True:
    try:
        s = input()
        res = jiexi(s)
        print(len(res))
        for i in res:
            print(i)
    except:
        break

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-23 14:22
点赞 评论 收藏
分享
06-07 17:17
嘉兴学院 教师
心爱的idea:你孩
点赞 评论 收藏
分享
zzzzhz:兄弟你先猛猛投简历至少三百家,能约到面试就去面。最近可以速成智能小车,智慧家居烂大街的项目,不需要自己写,只需要把里面的代码讲解看明白就行。把其中涉及到的八股文都拿出来单独背一下,我去年找工作就一个智能小车智慧家居找了10k差不多。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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