题解 | #坐标移动#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
1.使用split()函数进行切割 2.分成两部分 3.然后使用截取第一字符作为移动方向,第二个部分使用int([1:])结合try;except判断是否是整数,如果不是就无效 continue,如果是整数就移动
string = str(input())
x = 0
y = 0
for i in string.split(';'):
be = i[:1]
try:
s = int(i[1:])
except:
continue
if be=="A":
x -= s
if be=="D":
x += s
if be=="W":
y += s
if be=="S":
y -= s
print("{},{}".format(x,y))