Python正则 | #坐标移动#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
inpt = input() import re strs = inpt.split(";") A = 0 S = 0 W = 0 D = 0 c = ["A", "S", "W", "D"] for i in strs: if re.findall(r"^A\d+$", i): A -= int(i[1:]) if re.findall(r"^D\d+$", i): D += int(i[1:]) if re.findall(r"^W\d+$", i): W += int(i[1:]) if re.findall(r"^S\d+$", i): S -= int(i[1:]) print(str(A+D)+","+str(S+W))