Python 3.x 用于比较插件QGIS中2个不同数字的条件

Python 3.x 用于比较插件QGIS中2个不同数字的条件,python-3.x,qgis,Python 3.x,Qgis,我尝试制作插件来比较2个输入数字,但结果是这样的 Recomend = self.ui.btnProc QtCore.QObject.connect(Recomend, QtCore.SIGNAL('clicked()'),self.Compare1) def Compare1(self): input1 = self.ui.lineInput1.text() input2 = self.ui.line

我尝试制作插件来比较2个输入数字,但结果是这样的

  Recomend = self.ui.btnProc
            QtCore.QObject.connect(Recomend, QtCore.SIGNAL('clicked()'),self.Compare1)

        def Compare1(self):
            input1 = self.ui.lineInput1.text()
            input2 = self.ui.lineInput2.text()
            compare = ''
            if input1 == '' + input2:
                compare = 'input match'
            else
                compare = 'input doesnt match'
            self.ui.textRec1.setPlainText(compare)

  File "C:\Users\Mr.Pakde/.qgis2/python/plugins\condition\conditiondialog.py", line 40
    input2 = self.ui.lineInput2.text()
                                    ^
IndentationError: unindent does not match any outer indentation level
我用notepad++和PyScripter检查缩进错误,但仍然收到此错误消息


有人能帮帮我吗?

这是Python在混合制表符和空格时会给你的错误类型-最有可能的是,错误上方的行使用硬制表符缩进,错误所在的行使用空格缩进。Python对硬制表符使用的设置比您更宽,因此带有该设置的行会进一步缩进,即使在编辑器中看起来是一样的

不要混用它们,正是因为这会导致这些问题-选择硬制表符或空格,并将文本编辑器配置为在按“制表符”时这样做。你可以在谷歌上搜索各种各样的圣战,但选择一方并坚持到底

要在错误发生后修复错误,请将整个函数体取消缩进到左边距,然后将其重新缩进到适当的级别。在记事本++中,就像在许多其他编辑器中一样,您可以通过高亮显示所有这些行并按Shift+tab键取消登入,然后按tab键重新登入来完成此操作