题解 | #参数解析#

参数解析

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

while True:
    try:
        s = input()
        flag, temp, args = False, '', []
        for c in s + ' ':
            if c == '"':
                # 如果遇到引号,若标志位flag被打开,则关闭;否则将其开启
                flag = False if flag else True
                continue
            if c != ' ':
                temp += c
            else:
                if flag:
                    temp += c
                else:
                    args.append(temp)
                    temp = ''
        print(len(args))
        for a in args:
            print(a)
    except:
        break
全部评论
大佬厉害
点赞 回复 分享
发布于 2022-06-03 22:16

相关推荐

点赞 评论 收藏
分享
05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
评论
1
3
分享

创作者周榜

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