思路:通过标记flag来确认是否遇到空格会进行拆分
s = input() ns = '' flag = 0 l = [] for i in s: if i == '"': flag = not flag continue if flag: ns += i elif not flag and not i.isspace(): ns += i elif not flag and i.isspace(): l.append(ns) ns = '' l.append(ns) print(len(l)) for i in l: print(i)