0
我對Python文件進行簡單的測試得到這個問題,Python的縮進時錯誤的問題
class Prueba(object):
def __init__(self):
self.position = 0
def build_message(self, signal):
message = self.position
message = message | (0b1<<signal)
s = bin(message)
s = s[2:len(s)]
s = (16-len(s))*'0' + s
s0 = s[0:len(s)/2]
s1 = s[len(s)/2:len(s)]
s0 = s0[::-1]
s1 = s1[::-1]
s_final = int(s0 + s1, 2)
return s_final
def motor_activation(self):
rospy.logwarn("Preparing motor to start...")
if(self.drive_status[MC] == False and self.drive_status[READY] == False and self.drive_status[BRAKE] == False and self.drive_status[ERROR] == False):
rospy.sleep(1)
####### Avtivate FG_R #######
message = self.build_message(FG_R)
self.setBrModbusValue(2, message)
##Wait a little
rospy.sleep(1)
####### Avtivate FG_E #######
message = self.build_message(FG_E)
self.setBrModbusValue(2, message)
我試着用IPython中執行它,當得到這個消息:
message = self.position
^
IdentationError:expected an indented block
在哪條線路? – snufsan
你可以用不是notepad ++的編輯器編輯你的代碼嗎?標籤和空格有問題,除非某些設置是固定的。 –
標籤和空格的混合? – Gogo