题解 | #参数解析# python3解法

参数解析

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

通俗易懂 通过全部用例

while True:
    try:
        s=input()
        temp,res=[],[]
        for i,x in enumerate(s):
            if x=='"':
                temp.append(i)
        while temp:
            if s[temp[0]:temp[1]].find(' ')!=-1:
                a=s[temp[0]:temp[1]].replace(' ','++++')
                s=s[:temp[0]]+a+s[temp[1]+1:]
            temp.pop(0)
            temp.pop(0)
        res=s.split()
        for j in range(len(res)):
            res[j]=res[j].replace('++++',' ')
            if res[j].find('"')!=-1:
                res[j]=res[j].replace('"','')
        print(len(res))
        for k in res:
            print(k)
    except:
        break
全部评论

相关推荐

06-26 15:33
青岛工学院 Java
积极的秋田犬要冲国企:他现在邀请我明天面试
点赞 评论 收藏
分享
VirtualBoo...:都去逗他了?
点赞 评论 收藏
分享
评论
4
1
分享

创作者周榜

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