每次我嘗試執行這個腳本,我得到一個錯誤。 代碼: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