Text of docs.python.org › uk › 3 › library › urllib.error.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

urllib.error — Exception classes raised by urllib.request — Python 3.15.2 documentation

Навігація індекс модулі | наступний | попередній | Python » 3.15.2 documentation » The Python standard library » Інтернет-протоколи та підтримка » urllib.error — Exception classes raised by urllib.request | Theme | urllib.error — Exception classes raised by urllib.request ¶ Вихідний код: Lib/urllib/error.py The urllib.error module defines the exception classes for exceptions raised by urllib.request .

The base exception class is URLError . The following exceptions are raised by urllib.error as appropriate: exception urllib.error. URLError ¶ Обробники викликають цей виняток (або похідні виключення), коли стикаються з проблемою. Це підклас OSError . reason ¶ Причина цієї помилки. Це може бути рядок повідомлення або інший виняток.

Змінено в версії 3.3: URLError used to be a subtype of IOError , which is now an alias of OSError . exception urllib.error. HTTPError ( url , code , msg , hdrs , fp ) ¶ Хоча HTTPError і є винятком (підкласом URLError ),він також може функціонувати як невиключне значення, схоже на файл (те саме, що urlopen() повертає).

Це корисно під час обробки екзотичних помилок HTTP, таких як запити на автентифікацію. url ¶ Contains the request URL. An alias for filename attribute. code ¶ Код статусу HTTP, як визначено в RFC 2616 . Це числове значення відповідає значенню, знайденому в словнику кодів у http.server.BaseHTTPRequestHandler.responses . reason ¶ This is usually a string explaining the reason for this error.

An alias for msg attribute. headers ¶ The HTTP response headers for the HTTP request that caused the HTTPError . An alias for hdrs attribute. Added in version 3.4. fp ¶ A file-like object where the HTTP error body can be read from. exception urllib.error. ContentTooShortError ( msg , content ) ¶ This exception is raised when the urlretrieve() function detects that the amount of the downloaded data is less than the expected amount (given by the Content-Length header). content ¶ The downloaded (and supposedly truncated) data.

Попередній розділ urllib.parse — Parse URLs into components Наступна тема urllib.robotparser — Parser for robots.txt This page Report a bug Improve this page Show source Show translation source « Навігація індекс модулі | наступний | попередній | Python » 3.15.2 documentation » The Python standard library » Інтернет-протоколи та підтримка » urllib.error — Exception classes raised by urllib.request | Theme | © Авторське право 2001 Python Software Foundation.

This page is licensed under the Python Software Foundation License Version 2. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. See History and License for more information. The Python Software Foundation is a non-profit corporation. Please donate. Востаннє оновлено лист. 19, 2026 (11:14 UTC). Found a bug ? Created using Sphinx 9.1.1.