[英]Python Indentation Error Issue
我在一個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
這肯定是制表符混有空格的問題。
您可以通過在使用的編輯器中更改某些設置來將所有選項卡轉換為空格。
如果是精美文字:首選項->設置-用戶
嘗試將其另存為Packages / User / Preferences.sublime-settings
{
"tab_size": 4,
"translate_tabs_to_spaces": true
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.