这题研究时间长了
#先根据空格换行
cmd = input()
words = cmd.split()
my_str=''
#设置标志位if_return默认为True
if_return = True
for i in words:
#遇双引号开头则将换行开关置为False
if i.startswith('"')==True and i.endswith('"')==False:
if_return = False
#遇双引号结尾则将换行开关置为True
elif i.startswith('"')==False and i.endswith('"')==True:
if_return = True
#根据开关状态确定是否需要换行
if if_return==True:
my_str = my_str + i + '\n'
elif if_return==False:
my_str = my_str + i + ' '
print(my_str.count('\n'))
print(my_str.replace('"', ''))

京公网安备 11010502036488号