题解 | #坐标移动#
坐标移动
https://www.nowcoder.com/practice/119bcca3befb405fbe58abe9c532eb29
receive = input().split(";")
x,y=0,0
for i in receive:
if 1<len(i)<=3:
condition=i[1:]
if condition.isdigit():
if i[0]=='A':
x-=1*int(condition)
if i[0]=='D':
x+=1*int(condition)
if i[0]=='S':
y-=1*int(condition)
if i[0]=='W':
y+=1*int(condition)
print(str(x)+','+str(y))
Python isdigit() 方法检测字符串是否只由数字组成,只对 0 和 正数有效。
str.isdigit()
如果字符串只包含数字则返回 True 否则返回 False。
汤臣倍健公司氛围 361人发布