题解 | #参数解析#

参数解析

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

# key is to deal with ""
# when flag is off, split on space; when it's on, includes space


s = input() + ' '   # for the last element to be added to the list

f = False
p = ''
l = []

for i in s:
    if i == '"':
        f = not f

    elif not f and i == ' ':
        l.append(p)
        p = ''

    else:
        p += i

print(len(l))
for j in l:
    print(j)

参考题解 | #参数解析-巧妙将一长串分行打印#_钻石王老五的flag开关用法,用list容器处理

全部评论

相关推荐

这不纯纯作弊了吗😢😢😢
编程界菜鸡:信这个的这辈子有了,这智商你靠啥都没用
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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