环境:Windows10下的python3.8.1
运行如下代码:
while True:
for n in playerlis:
try:
players[str(n)].append(next(self.gencards))
except StopIteration:
print('finish')
break
期望无输出,实际输出如下:
Traceback (most recent call last):
File "F:\card.py", line 88, in __init__
self.players[str(n)].append(next(self.gencards))
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
a = onplayobj([1,2,3])
File "F:\card.py", line 90, in __init__
print('finish')
KeyboardInterrupt