字符串的分段组合问题 问题: 用户输入一个字符串s,以字符减号(+)分割s,将其中的首尾段用加号(-)组合输出 如表输入输出: 输入 输出 Learning+python+is+a+great+choice Leaning-choice 1+2+3+4+5+6+7+8 1-8 s = input(); str = s.split("+") print("{}-{}".format(str[0],str[-1])) 涉及知识点:split()方法,format()方法 相关文章: 2021-12-31 2021-11-26 2022-12-23 2022-01-12 2021-06-08 2022-12-23 2022-12-23