题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
s = input() s = s.replace(' ','\n') e = '' flag = False # 核心思想是先遍历一遍,用一个bool当做开关,把字符串参数里的空格,换成分割符以外的 for i in s: if i == '"': flag = not flag # 取反而不是赋值为False elif flag and i == '\n': e += ' ' else: e += i print(e.count('\n')+1) print(e)