题解 | #提取不重复的整数#
坐标移动
http://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
import re
drie = input().split(';')
d = []
for i in drie:
if re.match('[WASD][\d]', i):#正则筛选含有指定字母的字符串
d.append(i)
def countN(s):#统计字符串中字母的个数
num = 0
for i in s:
if i.isalpha():
num+=1
return num
x,y = 0 , 0
for i in d:
if countN(i)==1:
if 'A' in i:
x -= int(i[1:])
elif 'D' in i:
x += int(i[1:])
elif 'W' in i:
y += int(i[1:])
else:
y -= int(i[1:])
print('%d,%d'%(x,y))