Hari ini skrip sentiasa melaporkan ralat tamat masa. Apakah pengecualian pengendalian tamat masa?
Cuba kecuali di bawah tak guna
try:
url_open = urllib.request.urlopen(url)
except urllib.error.HTTPError:
print('HTTPError')
continue
except urllib.error.URLError:
print('URLError')
continue
Balik sahaja
File "F:\Program Files (x86)\Anaconda3\lib\http\client.py", line 612, in _safe_read
chunk = self.fp.read(min(amt, MAXAMOUNT))
File "F:\Program Files (x86)\Anaconda3\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
timeout: timed out
Tulis kecuali sebagai
except Exception:
Tiada guna
Cuba requests.get(url)