gpt4 book ai didi

python-3.x - 语法错误: in the “IF” block with Python

转载 作者:行者123 更新时间:2023-12-03 08:28:34 25 4
gpt4 key购买 nike

if new.upper() == "C":
first()
try:
a, b, c = re.split(r"(\s+)", new)
except ValueError:
return

The syntaxs error occures to the colon behind "C". if new.upper() == "C": What can i do to fix this problem?

最佳答案

您的缩进不正确。它应该看起来像。

if new.upper() == "C":
first()
try:
a, b, c = re.split(r"(\s+)", new)
except ValueError:
pass

另外,除非该代码段位于函数内部,否则请使用 pass而不是 return。因为return只能在函数内部使用。

编辑:
添加了正确的缩进点

关于python-3.x - 语法错误: in the “IF” block with Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33984415/

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