此python3代码的正确缩进是什么[重复]

问题描述 投票:0回答:1

我遇到错误

for quote in quotes:
                   ^

IndentationError:unindent与任何o不匹配子宫压痕水平

以下代码:-

if __name__ == "__main__":

    # Query the price once every N seconds.
    for _ in iter(range(N)):
        quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read())

        """ ----------- Update to get the ratio --------------- """
        prices = {}
    for quote in quotes:
      stock, bid_price, ask_price, price = getDataPoint(quote)
      print ("Quoted %s at (bid:%s, ask:%s, price:%s)" % (stock,bid_price, ask_price, price))
    print ("Ratio %s" % getRatio(prices['ABC'], prices['DEF']))
python-3.x error-handling indentation
1个回答
0
投票
在这里再次检查括号是否正确放置。

quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read())

© www.soinside.com 2019 - 2024. All rights reserved.