题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import re recmd = r"\w\d+$" heng = 0 zong = 0 listcmdsplit = input().split(';') for cmd in listcmdsplit: if len(cmd) <= 3 and re.match(recmd, cmd): if "A" in cmd: heng = heng - int(cmd[1:]) if "D" in cmd: heng = heng + int(cmd[1:]) if "W" in cmd: zong = zong + int(cmd[1:]) if "S" in cmd: zong = zong - int(cmd[1:]) print(f"{heng},{zong}")