import re x,y = map(str,input().split(',')) x1 = re.search('[-0-9]+',x).group() y1 = re.search('[-0-9]+',y).group() a = re.sub('[-0-9]+',y1,x) b = re.sub('[-0-9]+',x1,y) print(a,b,sep=',') 这个可以匹配任何格式的输入,例如a is -4,b is 45 name=43,age=65等