start_face = rotatestart_face direction evalfront back left right top bottomi = start_face报错为: evalfront back left right top bottomi = start_face ^SyntaxError cant assign to function call请修
可以使用字典来替代 eval 函数,避免出现 SyntaxError 错误:
start_face = rotate(start_face, direction) faces = {'front': 0, 'back': 1, 'left': 2, 'right': 3, 'top': 4, 'bottom': 5} globals()[list(faces.keys())[list(faces.values()).index(i)]] = start_face
或者使用多个变量来替代 eval 函数:
start_face = rotate(start_face, direction) if i == 0: front = start_face elif i == 1: back = start_face elif i == 2: left = start_face elif i == 3: right = start_face elif i == 4: top = start_face else: bottom = start_fac
原文地址: https://www.cveoy.top/t/topic/fFYU 著作权归作者所有。请勿转载和采集!