忽略输入中的换行符 for line in sys.stdin: a = line.strip('\n').split(',') 使用strip(‘\n’),忽略输入中的’\n’。 print()不换行 print('output', end='') 将end参数设为空(‘’),就可以了。