@@ -158,6 +158,11 @@ msgid ""
158
158
"notification e-mail messages that are completely unhelpful, so Ka-Ping Yee "
159
159
"wrote an HTML screen-scraper that sends more useful messages."
160
160
msgstr ""
161
+ "转向使用 SourceForge 的服务显著提高了开发速度。 "
162
+ "补丁现在由原提交者以外的人提交、评论、修改,并在不同人员之间来回传递,直到补丁被认为值得检入。 "
163
+ "程序错误在一个中心位置被跟踪,并可以分配给特定人员进行修复,我们还可以统计未解决程序错误的数量来衡量进度。 "
164
+ "这并不是没有代价的:开发人员现在需要处理更多的电子邮件,关注更多的邮件列表,并且需要为新环境编写专门的工具。 例如,SourceForge "
165
+ "发送的默认补丁和错误通知电子邮件完全无用,所以 Ka-Ping Yee 编写了一个 HTML 屏幕抓取器以便发送更有用的信息。"
161
166
162
167
#: ../../whatsnew/2.0.rst:95
163
168
msgid ""
@@ -233,6 +238,8 @@ msgid ""
233
238
"instead of the 8-bit number used by ASCII, meaning that 65,536 distinct "
234
239
"characters can be supported."
235
240
msgstr ""
241
+ "Python 2.0 中最大的新特性是引入了一种新的基本数据类型:Unicode 字符串。 Unicode 使用 16 位二进制数表示字符,而不是 "
242
+ "ASCII 所使用的 8 位,这意味着可以支持 65,536 个不同的字符。"
236
243
237
244
#: ../../whatsnew/2.0.rst:148
238
245
msgid ""
@@ -243,6 +250,9 @@ msgid ""
243
250
"was written up as :pep:`100`, \" Python Unicode Integration\" . This article "
244
251
"will simply cover the most significant points about the Unicode interfaces."
245
252
msgstr ""
253
+ "Unicode 支持的最终接口是通过在 python-dev 邮件列表上无数次激烈的讨论达成的,主要由 Marc-André Lemburg 基于 "
254
+ "Fredrik Lundh 的 Unicode 字符串类型实现来完成。 详细的接口说明被写成了 :pep:`100` \" Python Unicode "
255
+ "Integration\" 。 这篇文章只简单地涵盖关于 Unicode 接口的最重要信息。"
246
256
247
257
#: ../../whatsnew/2.0.rst:155
248
258
msgid ""
@@ -267,6 +277,11 @@ msgid ""
267
277
"installation by calling the ``sys.setdefaultencoding(encoding)`` function in"
268
278
" a customized version of :file:`site.py`."
269
279
msgstr ""
280
+ "Unicode 字符串和常规字符串一样,是一种不可变的序列类型。 它们可以被索引和切片,但不能原地修改。 Unicode 字符串有一个 "
281
+ "``encode( [encoding] )`` 方法,该方法返回一个以所需编码格式表示的 8 位字符串。 编码格式通过字符串命名,如 "
282
+ "``'ascii'``、``'utf-8'``、``'iso-8859-1'`` 等等。 为实现和注册新的编码格式定义了一个编解码器 "
283
+ "API,这些编码格式随后可在整个 Python 程序中使用。 如果未指定编码格式,默认编码格式通常是 7 位 ASCII,不过这可以通过在自定义版本的 "
284
+ ":file:`site.py` 模块中调用 ``sys.setdefaultencoding(encoding)`` 函数来更改。"
270
285
271
286
#: ../../whatsnew/2.0.rst:172
272
287
msgid ""
@@ -304,6 +319,10 @@ msgid ""
304
319
"errors to be silently ignored and ``'replace'`` uses U+FFFD, the official "
305
320
"replacement character, in case of any problems."
306
321
msgstr ""
322
+ "函数 ``unicode(string [, encoding] [, errors] )`` 从 8 位字符串创建一个 Unicode 字符串。 "
323
+ "``encoding`` 是一个指定使用编码格式的字符串。``errors`` 参数指定如何处理当前编码格式中无效的字符;传入 ``'strict'``"
324
+ " 作为参数值会在有任何编码错误时引发异常,而 ``'ignore'`` 会静默忽略错误,``'replace'`` 则在出现问题时使用 U+FFFD "
325
+ "即官方的替换字符。"
307
326
308
327
#: ../../whatsnew/2.0.rst:192
309
328
msgid ""
@@ -313,6 +332,8 @@ msgid ""
313
332
"some built-ins; if you find a built-in function that accepts strings but "
314
333
"doesn't accept Unicode strings at all, please report it as a bug.)"
315
334
msgstr ""
335
+ "``exec`` 语句,以及各种内置函数如 ``eval()``,``getattr()`` 和 ``setattr()`` 也会接受 Unicode "
336
+ "字符串和普通字符串。 (修复过程中可能会遗漏一些内置函数;如果你发现一个接受字符串但完全不接受 Unicode 字符串的内置函数,请报告此错误。)"
316
337
317
338
#: ../../whatsnew/2.0.rst:198
318
339
msgid ""
@@ -322,6 +343,10 @@ msgid ""
322
343
"that it's uppercase. ``unicodedata.bidirectional(u'\\ u0660')`` returns 'AN',"
323
344
" meaning that U+0660 is an Arabic number."
324
345
msgstr ""
346
+ "一个新的模块 :mod:`unicodedata` 提供了对 Unicode 字符属性的接口。 "
347
+ "例如,``unicodedata.category(u'A')`` 返回 2 个字符的字符串 'Lu',其中 'L' 表示这是一个字母,'u' "
348
+ "表示这是一个大写字母。 ``unicodedata.bidirectional(u'\\ u0660')`` 返回 'AN',表示 U+0660 "
349
+ "是一个阿拉伯数字。"
325
350
326
351
#: ../../whatsnew/2.0.rst:204
327
352
msgid ""
@@ -331,6 +356,9 @@ msgid ""
331
356
"4-element tuple: ``(encode_func, decode_func, stream_reader, "
332
357
"stream_writer)``."
333
358
msgstr ""
359
+ ":mod:`codecs` 模块包含查找现有编码格式和注册新编码格式的函数。 除非你想实现一个新的编码格式,否则你最常使用的是 "
360
+ "``codecs.lookup(encoding)`` 函数,它返回一个 4 元素的元组: ``(encode_func, decode_func, "
361
+ "stream_reader, stream_writer)``。"
334
362
335
363
#: ../../whatsnew/2.0.rst:209
336
364
msgid ""
@@ -340,6 +368,8 @@ msgid ""
340
368
"encoding, and *length* tells you how much of the Unicode string was "
341
369
"converted."
342
370
msgstr ""
371
+ "*encode_func* 是一个接受 Unicode 字符串的函数,并返回一个 2 元组 ``(string, length)``。 *string*"
372
+ " 是一个包含部分(可能是全部) Unicode 字符串转换为指定编码的 8 位字符串,*length* 告诉你转换了多少 Unicode 字符串。"
343
373
344
374
#: ../../whatsnew/2.0.rst:214
345
375
msgid ""
@@ -348,6 +378,8 @@ msgid ""
348
378
"Unicode string *ustring* and the integer *length* telling how much of the "
349
379
"8-bit string was consumed."
350
380
msgstr ""
381
+ "*decode_func* 与 *encode_func* 相反,它接受一个 8 位字符串并返回一个 2 元组 ``(ustring, "
382
+ "length)``,其中 *ustring* 是转换得到的 Unicode 字符串,*length* 是一个整数,表示消耗了多少 8 位字符串。"
351
383
352
384
#: ../../whatsnew/2.0.rst:219
353
385
msgid ""
@@ -369,18 +401,20 @@ msgstr ""
369
401
msgid ""
370
402
"For example, the following code writes a Unicode string into a file, "
371
403
"encoding it as UTF-8::"
372
- msgstr ""
404
+ msgstr "例如,以下的代码将 Unicode 字符串写入一个 UTF-8 编码的文件:: "
373
405
374
406
#: ../../whatsnew/2.0.rst:243
375
407
msgid "The following code would then read UTF-8 input from the file::"
376
- msgstr ""
408
+ msgstr "以下的代码则可以从文件中读取 UTF-8 输入:: "
377
409
378
410
#: ../../whatsnew/2.0.rst:249
379
411
msgid ""
380
412
"Unicode-aware regular expressions are available through the :mod:`re` "
381
413
"module, which has a new underlying implementation called SRE written by "
382
414
"Fredrik Lundh of Secret Labs AB."
383
415
msgstr ""
416
+ "支持 Unicode 的正则表达式可以通过 :mod:`re` 模块使用,该模块有一个新的底层实现称为 SRE,由 Secret Labs AB 的 "
417
+ "Fredrik Lundh 编写。"
384
418
385
419
#: ../../whatsnew/2.0.rst:253
386
420
msgid ""
@@ -390,6 +424,8 @@ msgid ""
390
424
"future version of Python may drop support for 8-bit strings and provide only"
391
425
" Unicode strings."
392
426
msgstr ""
427
+ "添加了一个 ``-U`` 命令行选项,使 Python 编译器将所有字符串字面量解释为 Unicode 字符串字面量。 这用于测试和为你的 Python"
428
+ " 代码提供未来保障,因为未来某个版本的 Python 可能会取消对 8 位字符串的支持,只提供 Unicode 字符串。"
393
429
394
430
#: ../../whatsnew/2.0.rst:262
395
431
msgid "List Comprehensions"
@@ -404,6 +440,9 @@ msgid ""
404
440
"might want to pull out all the strings containing a given substring, or "
405
441
"strip off trailing whitespace from each line."
406
442
msgstr ""
443
+ "列表是 Python 中的一种主力数据类型,许多程序在某个时候都会处理列表。 "
444
+ "对列表的两种常见操作是遍历它们,并筛选出符合某个条件的元素,或对每个元素应用某个函数。 "
445
+ "例如,给定一个字符串列表,你可能想要提取出所有包含特定子字符串的字符串,或去掉每行的尾随空白。"
407
446
408
447
#: ../../whatsnew/2.0.rst:271
409
448
msgid ""
@@ -416,17 +455,23 @@ msgid ""
416
455
"paragraph, finding all the strings in the list containing a given substring."
417
456
" You could write the following to do it::"
418
457
msgstr ""
458
+ "现有的 :func:`map` 和 :func:`filter` 函数可以用于此目的,但它们需要一个函数作为参数之一。 "
459
+ "如果有一个现有的内置函数可以直接传递,这是很好的,但如果没有,你必须创建一个小函数来完成所需的工作。 而 Python "
460
+ "的作用域规则会使结果变得丑陋,特别是如果这个小函数需要额外的信息。 以上一段中的第一个例子为例,找到列表中所有包含给定子字符串的字符串。 "
461
+ "你可以写如下代码来实现::"
419
462
420
463
#: ../../whatsnew/2.0.rst:286
421
464
msgid ""
422
465
"Because of Python's scoping rules, a default argument is used so that the "
423
466
"anonymous function created by the :keyword:`lambda` expression knows what "
424
467
"substring is being searched for. List comprehensions make this cleaner::"
425
468
msgstr ""
469
+ "由于 Python 的作用域规则,将会使用默认参数以使由 :keyword:`lambda` 表达式创建的匿名函数知道正在搜索哪个子字符串。 "
470
+ "列表推导能使这个过程更简洁::"
426
471
427
472
#: ../../whatsnew/2.0.rst:292
428
473
msgid "List comprehensions have the form::"
429
- msgstr ""
474
+ msgstr "列表推导式的形式如下:: "
430
475
431
476
#: ../../whatsnew/2.0.rst:299
432
477
msgid ""
@@ -438,12 +483,15 @@ msgid ""
438
483
":keyword:`!if` clause is optional; if present, *expression* is only "
439
484
"evaluated and added to the result if *condition* is true."
440
485
msgstr ""
486
+ ":keyword:`!for`...:keyword:`!in` 子句包含要迭代的序列。 这些序列不必具有相同的长度,因为它们 *不是* "
487
+ "并行迭代的,而是从左到右依次迭代;这一点将在以下段落中更清楚地解释。 生成列表的元素将是 *表达式* 的连续值。 最后的 :keyword:`!if` "
488
+ "子句是可选的;如果存在,只有当 *condition* 为真时,*表达式* 才会被求值并添加到结果中。"
441
489
442
490
#: ../../whatsnew/2.0.rst:307
443
491
msgid ""
444
492
"To make the semantics very clear, a list comprehension is equivalent to the "
445
493
"following Python code::"
446
- msgstr ""
494
+ msgstr "为了使语义更为清晰,列表推导相当于以下 Python 代码:: "
447
495
448
496
#: ../../whatsnew/2.0.rst:319
449
497
msgid ""
@@ -452,13 +500,17 @@ msgid ""
452
500
"all the sequences. If you have two lists of length 3, the output list is 9 "
453
501
"elements long::"
454
502
msgstr ""
503
+ "这意味着当有多个 :keyword:`!for`...:keyword:`!in` 子句时,生成的列表将等于所有序列长的的乘积。 如果你有两个长度为 3"
504
+ " 的列表,输出列表将有 9 个元素::"
455
505
456
506
#: ../../whatsnew/2.0.rst:330
457
507
msgid ""
458
508
"To avoid introducing an ambiguity into Python's grammar, if *expression* is "
459
509
"creating a tuple, it must be surrounded with parentheses. The first list "
460
510
"comprehension below is a syntax error, while the second one is correct::"
461
511
msgstr ""
512
+ "为了避免在 Python 的语法中引入歧义,如果 *表达式* 创建的是一个元组,它必须用括号括起来。 "
513
+ "下面的第一个列表推导式有语法错误,而第二个则是正确的::"
462
514
463
515
#: ../../whatsnew/2.0.rst:339
464
516
msgid ""
@@ -468,10 +520,13 @@ msgid ""
468
520
"comprehension patch, which was then discussed for a seemingly endless time "
469
521
"on the python-dev mailing list and kept up-to-date by Skip Montanaro."
470
522
msgstr ""
523
+ "列表推导的概念最初来自函数式编程语言 Haskell (https://www.haskell.org)。 Greg Ewing "
524
+ "最有力地提出了将其添加到 Python 中的建议,并编写了最初的列表推导式补丁,然后在 python-dev 邮件列表上进行了看似无休止的讨论,并由 "
525
+ "Skip Montanaro 保持更新。"
471
526
472
527
#: ../../whatsnew/2.0.rst:349
473
528
msgid "Augmented Assignment"
474
- msgstr ""
529
+ msgstr "增强赋值 "
475
530
476
531
#: ../../whatsnew/2.0.rst:351
477
532
msgid ""
@@ -481,6 +536,8 @@ msgid ""
481
536
" value of the variable ``a`` by 2, equivalent to the slightly lengthier ``a"
482
537
" = a + 2``."
483
538
msgstr ""
539
+ "增强赋值运算符,另一个长期以来要求添加的功能,已经被加入到 Python 2.0 中。 增强赋值运算符包括 ``+=``,``-=``,``*=`` "
540
+ "等。例如,语句 ``a += 2`` 将变量 ``a`` 的值增加 2,等同于稍长一些的 ``a = a + 2``。"
484
541
485
542
#: ../../whatsnew/2.0.rst:356
486
543
msgid ""
0 commit comments