Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
选项卡错误python_Python - Fatal编程技术网

选项卡错误python

选项卡错误python,python,Python,完全错误是TabError:缩进中制表符和空格的使用不一致 看起来我的间距是准确的,但显然不是。 有没有办法解决这个问题?我可能使用了不正确的python版本吗?return语句不需要任何选项卡。第19行 改变这个 到 您还可以在上检查您未来的python代码的缩进,听起来您是在混合使用制表符和空格来缩进行。。。不要那样做! import requests import subprocess import json import sys import threading import time

完全错误是TabError:缩进中制表符和空格的使用不一致 看起来我的间距是准确的,但显然不是。 有没有办法解决这个问题?我可能使用了不正确的python版本吗?

return语句不需要任何选项卡。第19行 改变这个


您还可以在

上检查您未来的python代码的缩进,听起来您是在混合使用制表符和空格来缩进行。。。不要那样做!
import requests
import subprocess
import json
import sys
import threading
import time
from Queue import Queue

numberOfViewers = int(sys.argv[1])
builderThreads = int(sys.argv[2])
startTime = time.time()
numberOfSockets = 0
concurrent = 25
urls = []
urlsUsed = []

def getURL(): # Get tokens
  output = subprocess.Popen(["livestreamer", "http://www.twitch.tv/gbowtheking", "-j"], stdout=subprocess.PIPE).communicate()[0]   #replace twitch.tv/??? with your channel
        return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter

def build(): # Builds a set of tokens, aka viewers
        global numberOfSockets
        global numberOfViewers
        while True:
                if numberOfSockets < numberOfViewers:
                        numberOfSockets += 1
                        print "Building viewers " + str(numberOfSockets) + "/" + str(numberOfViewers)
                        urls.append(getURL())

def view(): # Opens connections to send views
        global numberOfSockets
        while True:
                url=q.get()
                requests.head(url)
                if (url in urlsUsed):
                        urls.remove(url)
                        urlsUsed.remove(url)
                        numberOfSockets -= 1
                else:
                        urlsUsed.append(url)
                q.task_done()

if __name__ == '__main__':
        for i in range(0, builderThreads):
                threading.Thread(target = build).start()

        while True:
                while (numberOfViewers != numberOfSockets): # Wait until sockets are built
                        time.sleep(1)

                q=Queue(concurrent*2)
                for i in range(concurrent):
                        try:
                                t=threading.Thread(target=view)
                                t.daemon=True
                                t.start()
                        except:
                                print 'thread error'
                try:
                        for url in urls:
                                print url
                                q.put(url.strip())
                                q.join()
                except KeyboardInterrupt:
                        sys.exit(1)
return json.loads(output)['streams']['worst']['url']
def getURL(): # Get tokens
  output = subprocess.Popen(["livestreamer", "http://www.twitch.tv/gbowtheking", "-j"], stdout=subprocess.PIPE).communicate()[0]   #replace twitch.tv/??? with your channel
        return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter
def getURL(): # Get tokens
  output = subprocess.Popen(["livestreamer", "http://www.twitch.tv/gbowtheking", "-j"], stdout=subprocess.PIPE).communicate()[0]   #replace twitch.tv/??? with your channel
  return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter