题解 | #参数解析#
参数解析
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容器处理