题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
route = input() route_list = route.split(";") #变成列表,["A10", "S20", ...] loc = [0,0] import re for i in route_list: if re.match("A\d{1,2}$",i): loc[0] -= int(i[1:]) elif re.match("D\d{1,2}$",i): loc[0] += int(i[1:]) elif re.match("W\d{1,2}",i): loc[1] += int(i[1:]) elif re.match("S\d{1,2}",i): loc[1] -= int(i[1:]) else: continue print("{},{}".format(loc[0],loc[1]))