我知道eval
不好,我对编码很陌生
我使用配置解析器来定义打开输出门以转移部件的马达
从我的配置文件:
[Motor]out1=["Screw", "board0.motor1"]
代码
out1=json.loads(config['Motor']['out1'])
board0 = MotorKit(address= int(config['Motor']['board0'], 16))
def openMotor(m):
eval(m).throttle = 1
time.sleep(0.1)
eval(m).throttle = 0.2
def open_gate(part):
if part == out1[0]:
openMotor(out1[1])
open_gate("screw")
我如何不使用eval
?但是能够在openMotor
函数中设置属性board0.motor1.throttle
目前没有回答
相关问题 更多 >
编程相关推荐