我有一个连接到服务器以向其发送一些命令的 python 程序,但有时我会收到此错误
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
在以前这样的情况下,我会使用这样的东西
try:
do something
except KeyError:
do something else
我可以在同样的情况下做同样的事情吗?
try:
do something
except TimeoutError:
do something again
如果是这样,我会在除了 TimeoutError 之后做什么?我会再次执行相同的命令吗?