每次我尝试执行这个脚本,我得到一个错误。 代码:Python错误,IndentationError:意外缩进
def getURL(): # Get tokens
output = subprocess.Popen(["livestreamer", "twitch.tv/CHANNEL_NAME", "-j"], stdout=subprocess.PIPE).communicate()[0]
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())
错误:
File "sript.py", line 19
return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter
^
IndentationError: unexpected indent
这个问题似乎是题外话,因为它是关于一个基本的语法错误 – lifetimes