题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import re cmds = input().split(';') res = [0,0] for i in cmds: ret = re.match(pattern='^[AWSD][0-9]{1,2}$',string=i) if not ret: continue else: i = ret.group() # print(i) if i[0]=='A': res[0]-=int(i[1:]) elif i[0]=='D': res[0]+=int(i[1:]) elif i[0]=='W': res[1]+=int(i[1:]) elif i[0]=='S': res[1]-=int(i[1:]) print(res[0],res[1],sep=',')