需要python帮助

use*_*004 -1 python indentation

import os
import sys, urllib2, urllib
import re
import time
from threading import Thread

class testit(Thread):
   def __init__ (self):
      Thread.__init__(self)
   def run(self):
        url = 'http://games.espnstar.asia/the-greatest-odi/post_brackets.php'
        data = urllib.urlencode([('id',"btn_13_9_13"),  ('matchNo',"13")])
        req = urllib2.Request(url)
        fd = urllib2.urlopen(req, data)
<TAB>fd.close()
<TAB>"""while 1:
                data = fd.read(1024)
                if not len(data):
                        break
                sys.stdout.write(data)"""
        url2 = 'http://games.espnstar.asia/the-greatest-odi/post_perc.php'
        data2 = urllib.urlencode([('id',"btn_13_9_13"),  ('matchNo',"13")])
        req2 = urllib2.Request(url2)
        fd2 = urllib2.urlopen(req2, data2)
<TAB>#prints current votes
        while 1:
                data2 = fd2.read(1024)
                if not len(data2):
                        break
                sys.stdout.write(data2)
<TAB>fd2.close()
        print time.ctime()
        print " ending thread\n"

i=-1
while i<0:
   current = testit()
   time.sleep(0.001) #decrease this like 0.0001 for more loops
   current.start()
Run Code Online (Sandbox Code Playgroud)

嘿,任何人都可以帮我找出代码中的错误它说不一致使用制表符缩进空格

joe*_*ker 5

我编辑了你的帖子以替换所有标签<TAB>.您需要删除这些行上的缩进并使用空格将其重新排列.有些编辑可以为您做到这一点,但我不知道您使用的编辑器.

如果您认真对待Python,则应该重新配置编辑器,以便在按下Tab键时始终插入4个空格.您还可以尝试更改制表符字符提供的缩进量,或者在某些编辑器中打印制表符的可见符号,以便您可以查看问题所在.

  • 你是一个善良的灵魂.现在你可以帮助OP在周二晚上为他的办公室进行真空管理;-) (2认同)