@@ -222,17 +222,17 @@ msgstr "具体操作如下::"
222222msgid ""
223223"Notice that the full URL is created by adding a ``?`` to the URL, followed "
224224"by the encoded values."
225- msgstr ""
225+ msgstr "请注意,完整的 URL 是通过在其中添加 ``?`` 创建的,后面跟着经过编码的数据。 "
226226
227227#: ../../howto/urllib2.rst:165
228228msgid "Headers"
229- msgstr ""
229+ msgstr "HTTP 头部信息 "
230230
231231#: ../../howto/urllib2.rst:167
232232msgid ""
233233"We'll discuss here one particular HTTP header, to illustrate how to add "
234234"headers to your HTTP request."
235- msgstr ""
235+ msgstr "下面介绍一个具体的 HTTP 头部信息,以此说明如何在 HTTP 请求加入头部信息。 "
236236
237237#: ../../howto/urllib2.rst:170
238238msgid ""
@@ -246,13 +246,18 @@ msgid ""
246246"the same request as above, but identifies itself as a version of Internet "
247247"Explorer [#]_. ::"
248248msgstr ""
249+ "有些网站 [#]_ 不愿被程序浏览到,或者要向不同的浏览器发送不同版本 [#]_ 的网页。默认情况下,urllib 将自身标识为“Python-"
250+ "urllib/xy”(其中 ``x`` 、 ``y`` 是 Python 版本的主、次版本号,例如 ``Python-"
251+ "urllib/2.5``),这可能会让网站不知所措,或者干脆就使其无法正常工作。浏览器是通过头部信息 ``User-Agent`` [#]_ "
252+ "来标识自己的。在创建 Request 对象时,可以传入字典形式的头部信息。以下示例将生成与之前相同的请求,只是将自身标识为某个版本的 Internet "
253+ "Explorer [#]_ :"
249254
250255#: ../../howto/urllib2.rst:197
251256msgid ""
252257"The response also has two useful methods. See the section on `info and "
253258"geturl`_ which comes after we have a look at what happens when things go "
254259"wrong."
255- msgstr ""
260+ msgstr "响应对象也有两个很有用的方法。请参阅有关 `info 和 geturl`_ 部分,了解出现问题时会发生什么。 "
256261
257262#: ../../howto/urllib2.rst:202
258263msgid "Handling Exceptions"
@@ -264,12 +269,14 @@ msgid ""
264269" usual with Python APIs, built-in exceptions such as :exc:`ValueError`, "
265270":exc:`TypeError` etc. may also be raised)."
266271msgstr ""
272+ "如果 *urlopen* 无法处理响应信息,就会触发 :exc:`URLError` 。尽管与通常的 Python API 一样,也可能触发 "
273+ ":exc:`ValueError` 、 :exc:`TypeError` 等内置异常。"
267274
268275#: ../../howto/urllib2.rst:208
269276msgid ""
270277":exc:`HTTPError` is the subclass of :exc:`URLError` raised in the specific "
271278"case of HTTP URLs."
272- msgstr ""
279+ msgstr ":exc:`HTTPError` 是 :exc:`URLError` 的子类,当 URL 是 HTTP 的情况时将会触发。 "
273280
274281#: ../../howto/urllib2.rst:211
275282msgid ""
@@ -318,13 +325,13 @@ msgstr ""
318325#: ../../howto/urllib2.rst:242
319326msgid ""
320327"See section 10 of :rfc:`2616` for a reference on all the HTTP error codes."
321- msgstr ""
328+ msgstr "全部的 HTTP 错误码请参阅 :rfc:`2616` 。 "
322329
323330#: ../../howto/urllib2.rst:244
324331msgid ""
325332"The :exc:`HTTPError` instance raised will have an integer 'code' attribute, "
326333"which corresponds to the error sent by the server."
327- msgstr ""
334+ msgstr ":exc:`HTTPError` 实例将包含一个整数型的“code”属性,对应于服务器发来的错误。 "
328335
329336#: ../../howto/urllib2.rst:248
330337msgid "Error Codes"
@@ -336,13 +343,16 @@ msgid ""
336343"codes in the 100--299 range indicate success, you will usually only see "
337344"error codes in the 400--599 range."
338345msgstr ""
346+ "由于默认处理函数会自行处理重定向(300 以内的错误码),而且 100--299 的状态码表示成功,因此通常只会出现 400--599 的错误码。 "
339347
340348#: ../../howto/urllib2.rst:254
341349msgid ""
342350":attr:`http.server.BaseHTTPRequestHandler.responses` is a useful dictionary "
343351"of response codes in that shows all the response codes used by :rfc:`2616`. "
344352"The dictionary is reproduced here for convenience ::"
345353msgstr ""
354+ ":attr:`http.server.BaseHTTPRequestHandler.responses` 是很有用的响应码字典,其中给出了 "
355+ ":rfc:`2616` 用到的所有响应代码。为方便起见,下面将此字典转载如下:"
346356
347357#: ../../howto/urllib2.rst:326
348358msgid ""
0 commit comments