题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
- 先用引号分割,将所有第偶数个子字符串(括号内的字符串)作为一个参数
- 用空格分割第奇数个字符串,统计包含的参数个数
while True: try: cmd = input().split('"') params = [] for i in range(len(cmd)): if i % 2 != 0: params.append(cmd[i]) else: cmd_sub = cmd[i].split() params += cmd_sub print(len(params)) print('\n'.join(params)) except EOFError: break