题解 | #坐标移动#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
用字符串isdigit()方法检验输入坐标是否仅由数字组成
while True:
try:
s = input().split(';')
init = [0, 0]
for i in s:
if not 2 <= len(i) <= 3:
continue
if i[0] == 'A':
if i[1:].isdigit():
init[0] -= int(i[1:])
elif i[0] == 'D':
if i[1:].isdigit():
init[0] += int(i[1:])
elif i[0] == 'W':
if i[1:].isdigit():
init[1] += int(i[1:])
elif i[0] == 'S':
if i[1:].isdigit():
init[1] -= int(i[1:])
print(init[0], end=',')
print(init[1])
except:
break