我有下面的代码来做一些ocr的东西。当这完成后,我想生成一些窗口。但是,每当我运行我的代码,我得到了第13行的以下错误:unindent does not match any outer indentation level
我认为这很奇怪,因为我没有看到我的代码中有任何奇怪的缩进。见下面我的代码:tkinter上的python缩进错误
import Tkinter as tk
from os import *
from PIL import Image
from tesserocr import PyTessBaseAPI, RIL
root = tk.Tk()
tk.Label(root, text="this is the root window").pack()
root.geometry("200x20")
def window(x, y, w, h):
display = tk.Toplevel()
线下生成错误:
display.geometry('%dx%d+%d+%d' % (w, h, x, y))
tk.Label(display, text="sensitive info").pack()
def main():
path = "~/Desktop/media_argeology/Check_sensitive/"
system("mkdir -p {0}".format(path))
system("screencapture {0}temp.png".format(path))
system('sips -Z 4000 temp.png')
image = Image.open('temp.png')
with PyTessBaseAPI() as api:
api.SetImage(image)
boxes = api.GetComponentImages(RIL.TEXTLINE, True)
for i, (im, box, _, _) in enumerate(boxes):
window(box['x'], box['y'], box['w'], box['h'])
print "exit first function"
main()
root.mainloop()
我是很新的蟒蛇,但我有其他语言的一些编程经验。任何帮助是极大的赞赏!
你可能有标签和空格的代码中的组合。这是我最好的猜测 – SarathSprakash
没问题给它一张支票 – FutureCake
你甚至可以在问题的源头看到它。 'display = ...'这一行用一个制表符缩进,下面一行用四个空格。 –