You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/机器.py

25 lines
550 B

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 10 09:38:17 2022
@author: Administrator
"""
inst=input().split(',')#输入的指令保存在列表变量inst中
######BEGIN######
dict1={}
for i in inst:
if i[0]=='U':
dict1['u']=int(i[2:])
elif i[0]=='D':
dict1['d']=int(i[4:])
elif i[0]=='L':
dict1['l']=int(i[4:])
elif i[0]=='R':
dict1['r']=int(i[5:])
y=dict1.get('u',0)-dict1.get('d',0)
x=dict1.get('r',0)-dict1.get('l',0)
list1=[]
list1.append(x)
list1.append(y)
print(list1)