-3
是不是好有空尝试除蟒finally块,这样的事情,终于尝试 - EMPTY尝试除了最后在python中有效吗?
try:
#nothing here,
except:
#nothing here as well,
finally:
#nothing here too.
是不是好有空尝试除蟒finally块,这样的事情,终于尝试 - EMPTY尝试除了最后在python中有效吗?
try:
#nothing here,
except:
#nothing here as well,
finally:
#nothing here too.
当然,你可以使用pass
传递块:
try:
pass
except:
pass
finally:
pass
更多的例子:
def a():
pass
while True:
pass
for i in range(10):
pass
...
时间字面上在while循环中传递。 – VPfB
只需运行你的(无意义的)代码。 –
您的区块不完全是空的 - 每个区域都有注释。你的意思是完全空的,只包含注释,只包含'pass'语句或其他内容?你为什么不试试每一个,看看会发生什么? –
@RoryDaulton解析器忽略注释;他们不能作为至少需要一个的陈述。 – chepner