gpt4 book ai didi

python - IndentationError : expected an indented block Can someone help me

转载 作者:行者123 更新时间:2023-12-02 10:56:37 29 4
gpt4 key购买 nike

我收到缩进错误(IndentationError:应为缩进块)
有人可以帮忙吗
def downloadVideo():

x = entry.get()

logging.debug(x + " - Done")
ydl_opts = {} --------------------------------------- I get error here
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([x])

代码再次()def downloadVideo():
x = entry.get()

logging.debug(x + " - Done")
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([x])

最佳答案

您需要缩进这一行:

ydl.download([x])

因此,生成的代码应类似于:
x = entry.get()

logging.debug(x + " - Done")
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([x])

Python需要缩进而不是大括号,就像您可能习惯的其他编程语言一样。

关于python - IndentationError : expected an indented block Can someone help me,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62088996/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com