-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathintroduction.po
More file actions
527 lines (454 loc) · 30.8 KB
/
introduction.po
File metadata and controls
527 lines (454 loc) · 30.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2023, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Shengjing Zhu <zsj950618@gmail.com>, 2019
# eric R <trencyclopedia@gmail.com>, 2019
# Woko <banbooliu@gmail.com>, 2019
# df2dc1c92e792f7ae8417c51df43db8f_594d92a <0f49be28017426edb1db1a2ab6e67088_717605>, 2019
# Freesand Leo <yuqinju@163.com>, 2022
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.7\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-24 14:40+0000\n"
"PO-Revision-Date: 2019-09-01 02:41+0000\n"
"Last-Translator: Freesand Leo <yuqinju@163.com>, 2022\n"
"Language-Team: Chinese (China) (https://www.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:5
msgid "An Informal Introduction to Python"
msgstr "Python 的非正式介绍"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:7
msgid ""
"In the following examples, input and output are distinguished by the "
"presence or absence of prompts (:term:`>>>` and :term:`...`): to repeat the "
"example, you must type everything after the prompt, when the prompt appears;"
" lines that do not begin with a prompt are output from the interpreter. Note"
" that a secondary prompt on a line by itself in an example means you must "
"type a blank line; this is used to end a multi-line command."
msgstr ""
"在下面的例子中,通过提示符 (:term:`>>>` 与 :term:`...`) "
"的出现与否来区分输入和输出:如果你想复现这些例子,当提示符出现后,你必须在提示符后键入例子中的每一个词;不以提示符开头的那些行是解释器的输出。注意例子中某行中出现第二个提示符意味着你必须键入一个空白行;这是用来结束多行命令的。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:16
msgid ""
"Many of the examples in this manual, even those entered at the interactive "
"prompt, include comments. Comments in Python start with the hash character,"
" ``#``, and extend to the end of the physical line. A comment may appear at"
" the start of a line or following whitespace or code, but not within a "
"string literal. A hash character within a string literal is just a hash "
"character. Since comments are to clarify code and are not interpreted by "
"Python, they may be omitted when typing in examples."
msgstr ""
"这个手册中的许多例子都包含注释,甚至交互性命令中也有。Python中的注释以井号 ``#`` "
"开头,并且一直延伸到该文本行结束为止。注释可以出现在一行的开头或者是空白和代码的后边,但是不能出现在字符串中间。字符串中的井号就是井号。因为注释是用来阐明代码的,不会被"
" Python 解释,所以在键入这些例子时,注释是可以被忽略的。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:24
msgid "Some examples::"
msgstr "几个例子::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:35
msgid "Using Python as a Calculator"
msgstr "Python 作为计算器使用"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:37
msgid ""
"Let's try some simple Python commands. Start the interpreter and wait for "
"the primary prompt, ``>>>``. (It shouldn't take long.)"
msgstr "让我们尝试一些简单的 Python 命令。启动解释器,等待界面中的提示符,``>>>`` (这应该花不了多少时间)。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:44
msgid "Numbers"
msgstr "数字"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:46
msgid ""
"The interpreter acts as a simple calculator: you can type an expression at "
"it and it will write the value. Expression syntax is straightforward: the "
"operators ``+``, ``-``, ``*`` and ``/`` work just like in most other "
"languages (for example, Pascal or C); parentheses (``()``) can be used for "
"grouping. For example::"
msgstr ""
"解释器就像一个简单的计算器一样:你可以在里面输入一个表达式然后它会写出答案。 表达式的语法很直接:运算符 ``+``、``-``、``*``、``/``"
" 的用法和其他大部分语言一样(比如 Pascal 或者 C 语言);括号 (``()``) 用来分组。比如::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:61
msgid ""
"The integer numbers (e.g. ``2``, ``4``, ``20``) have type :class:`int`, the "
"ones with a fractional part (e.g. ``5.0``, ``1.6``) have type "
":class:`float`. We will see more about numeric types later in the tutorial."
msgstr ""
"整数(比如 ``2``、``4``、``20`` )有 :class:`int` 类型,有小数部分的(比如 ``5.0``、``1.6`` )有 "
":class:`float` 类型。在这个手册的后半部分我们会看到更多的数值类型。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:65
msgid ""
"Division (``/``) always returns a float. To do :term:`floor division` and "
"get an integer result (discarding any fractional result) you can use the "
"``//`` operator; to calculate the remainder you can use ``%``::"
msgstr ""
"除法运算 (``/``) 永远返回浮点数类型。如果要做 :term:`floor division` 得到一个整数结果(忽略小数部分)你可以使用 "
"``//`` 运算符;如果要计算余数,可以使用 ``%`` ::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:79
msgid ""
"With Python, it is possible to use the ``**`` operator to calculate powers "
"[#]_::"
msgstr "在Python中,可以使用 ``**`` 运算符来计算乘方 [#]_ ::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:86
msgid ""
"The equal sign (``=``) is used to assign a value to a variable. Afterwards, "
"no result is displayed before the next interactive prompt::"
msgstr "等号 (``=``) 用于给一个变量赋值。然后在下一个交互提示符之前不会有结果显示出来::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:94
msgid ""
"If a variable is not \"defined\" (assigned a value), trying to use it will "
"give you an error::"
msgstr "如果一个变量未定义(未赋值),试图使用它时会向你提示错误::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:102
msgid ""
"There is full support for floating point; operators with mixed type operands"
" convert the integer operand to floating point::"
msgstr "Python中提供浮点数的完整支持;包含多种混合类型运算数的运算会把整数转换为浮点数::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:108
msgid ""
"In interactive mode, the last printed expression is assigned to the variable"
" ``_``. This means that when you are using Python as a desk calculator, it "
"is somewhat easier to continue calculations, for example::"
msgstr "在交互模式下,上一次打印出来的表达式被赋值给变量 ``_``。这意味着当你把Python用作桌面计算器时,继续计算会相对简单,比如::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:121
msgid ""
"This variable should be treated as read-only by the user. Don't explicitly "
"assign a value to it --- you would create an independent local variable with"
" the same name masking the built-in variable with its magic behavior."
msgstr "这个变量应该被使用者当作是只读类型。不要向它显式地赋值——你会创建一个和它名字相同独立的本地变量,它会使用魔法行为屏蔽内部变量。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:125
msgid ""
"In addition to :class:`int` and :class:`float`, Python supports other types "
"of numbers, such as :class:`~decimal.Decimal` and "
":class:`~fractions.Fraction`. Python also has built-in support for "
":ref:`complex numbers <typesnumeric>`, and uses the ``j`` or ``J`` suffix to"
" indicate the imaginary part (e.g. ``3+5j``)."
msgstr ""
"除了 :class:`int` 和 :class:`float`,Python也支持其他类型的数字,例如 "
":class:`~decimal.Decimal` 或者 :class:`~fractions.Fraction`。Python 也内置对 "
":ref:`复数 <typesnumeric>` 的支持,使用后缀 ``j`` 或者 ``J`` 就可以表示虚数部分(例如 ``3+5j`` )。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:135
msgid "Strings"
msgstr "字符串"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:137
msgid ""
"Besides numbers, Python can also manipulate strings, which can be expressed "
"in several ways. They can be enclosed in single quotes (``'...'``) or "
"double quotes (``\"...\"``) with the same result [#]_. ``\\`` can be used "
"to escape quotes::"
msgstr ""
"除了数字,Python 也可以操作字符串。字符串有多种形式,可以使用单引号(``'...'``),双引号(``\"...\"``)都可以获得同样的结果 "
"[#]_。反斜杠 ``\\`` 可以用来转义::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:155
msgid ""
"In the interactive interpreter, the output string is enclosed in quotes and "
"special characters are escaped with backslashes. While this might sometimes"
" look different from the input (the enclosing quotes could change), the two "
"strings are equivalent. The string is enclosed in double quotes if the "
"string contains a single quote and no double quotes, otherwise it is "
"enclosed in single quotes. The :func:`print` function produces a more "
"readable output, by omitting the enclosing quotes and by printing escaped "
"and special characters::"
msgstr ""
"在交互式解释器中,输出的字符串外面会加上引号,特殊字符会使用反斜杠来转义。 "
"虽然有时这看起来会与输入不一样(外面所加的引号可能会改变),但两个字符串是相同的。 "
"如果字符串中有单引号而没有双引号,该字符串外将加双引号来表示,否则就加单引号。 :func:`print` "
"函数会生成可读性更强的输出,即略去两边的引号,并且打印出经过转义的特殊字符::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:175
msgid ""
"If you don't want characters prefaced by ``\\`` to be interpreted as special"
" characters, you can use *raw strings* by adding an ``r`` before the first "
"quote::"
msgstr "如果你不希望前置了 ``\\`` 的字符转义成特殊字符,可以使用 *原始字符串* 方式,在引号前添加 ``r`` 即可::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:185
msgid ""
"String literals can span multiple lines. One way is using triple-quotes: "
"``\"\"\"...\"\"\"`` or ``'''...'''``. End of lines are automatically "
"included in the string, but it's possible to prevent this by adding a ``\\``"
" at the end of the line. The following example::"
msgstr ""
"字符串字面值可以包含多行。 一种实现方式是使用三重引号:``\"\"\"...\"\"\"`` 或 ``'''...'''``。 "
"字符串中将自动包括行结束符,但也可以在换行的地方添加一个 ``\\`` 来避免此情况。 参见以下示例:"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:196
msgid ""
"produces the following output (note that the initial newline is not "
"included):"
msgstr "输出如下(请注意开始的换行符没有被包括在内):"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:204
msgid ""
"Strings can be concatenated (glued together) with the ``+`` operator, and "
"repeated with ``*``::"
msgstr "字符串可以用 ``+`` 进行连接(粘到一起),也可以用 ``*`` 进行重复::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:211
msgid ""
"Two or more *string literals* (i.e. the ones enclosed between quotes) next "
"to each other are automatically concatenated. ::"
msgstr "相邻的两个或多个 *字符串字面值* (引号引起来的字符)将会自动连接到一起. ::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:217
msgid ""
"This feature is particularly useful when you want to break long strings::"
msgstr "拼接分隔开的长字符串时,这个功能特别实用:"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:224
msgid ""
"This only works with two literals though, not with variables or "
"expressions::"
msgstr "只能对两个字面值这样操作,变量或表达式不行::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:238
msgid ""
"If you want to concatenate variables or a variable and a literal, use "
"``+``::"
msgstr "如果你想连接变量,或者连接变量和字面值,可以用 ``+`` 号::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:243
msgid ""
"Strings can be *indexed* (subscripted), with the first character having "
"index 0. There is no separate character type; a character is simply a string"
" of size one::"
msgstr "字符串是可以被 *索引* (下标访问)的,第一个字符索引是 0。单个字符并没有特殊的类型,只是一个长度为一的字符串::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:253
msgid ""
"Indices may also be negative numbers, to start counting from the right::"
msgstr "索引也可以用负数,这种会从右边开始数::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:262
msgid "Note that since -0 is the same as 0, negative indices start from -1."
msgstr "注意 -0 和 0 是一样的,所以负数索引从 -1 开始。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:264
msgid ""
"In addition to indexing, *slicing* is also supported. While indexing is "
"used to obtain individual characters, *slicing* allows you to obtain "
"substring::"
msgstr "除了索引,字符串还支持 *切片*。索引可以得到单个字符,而 *切片* 可以获取子字符串::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:272
msgid ""
"Note how the start is always included, and the end always excluded. This "
"makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::"
msgstr "注意切片的开始总是被包括在结果中,而结束不被包括。这使得 ``s[:i] + s[i:]`` 总是等于 ``s`` ::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:280
msgid ""
"Slice indices have useful defaults; an omitted first index defaults to zero,"
" an omitted second index defaults to the size of the string being sliced. ::"
msgstr "切片的索引有默认值;省略开始索引时默认为0,省略结束索引时默认为到字符串的结束::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:290
msgid ""
"One way to remember how slices work is to think of the indices as pointing "
"*between* characters, with the left edge of the first character numbered 0. "
"Then the right edge of the last character of a string of *n* characters has "
"index *n*, for example::"
msgstr ""
"您也可以这么理解切片:将索引视作指向字符 *之间* ,第一个字符的左侧标为0,最后一个字符的右侧标为 *n* ,其中 *n* 是字符串长度。例如::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:301
msgid ""
"The first row of numbers gives the position of the indices 0...6 in the "
"string; the second row gives the corresponding negative indices. The slice "
"from *i* to *j* consists of all characters between the edges labeled *i* and"
" *j*, respectively."
msgstr ""
"第一行数标注了字符串 0...6 的索引的位置,第二行标注了对应的负的索引。那么从 *i* 到 *j* 的切片就包括了标有 *i* 和 *j* "
"的位置之间的所有字符。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:306
msgid ""
"For non-negative indices, the length of a slice is the difference of the "
"indices, if both are within bounds. For example, the length of "
"``word[1:3]`` is 2."
msgstr "对于使用非负索引的切片,如果索引不越界,那么得到的切片长度就是起止索引之差。例如, ``word[1:3]`` 的长度为2。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:310
msgid "Attempting to use an index that is too large will result in an error::"
msgstr "试图使用过大的索引会产生一个错误::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:317
msgid ""
"However, out of range slice indexes are handled gracefully when used for "
"slicing::"
msgstr "但是,切片中的越界索引会被自动处理::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:325
msgid ""
"Python strings cannot be changed --- they are :term:`immutable`. Therefore, "
"assigning to an indexed position in the string results in an error::"
msgstr "Python 中的字符串不能被修改,它们是 :term:`immutable` 的。因此,向字符串的某个索引位置赋值会产生一个错误::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:337
msgid "If you need a different string, you should create a new one::"
msgstr "如果需要一个不同的字符串,应当新建一个::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:344
msgid "The built-in function :func:`len` returns the length of a string::"
msgstr "内建函数 :func:`len` 返回一个字符串的长度::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:355
msgid ":ref:`textseq`"
msgstr ":ref:`textseq`"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:354
msgid ""
"Strings are examples of *sequence types*, and support the common operations "
"supported by such types."
msgstr "字符串是一种 *序列类型* ,因此也支持序列类型的各种操作。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:359
msgid ":ref:`string-methods`"
msgstr ":ref:`string-methods`"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:358
msgid ""
"Strings support a large number of methods for basic transformations and "
"searching."
msgstr "字符串支持许多变换和查找的方法。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:362
msgid ":ref:`f-strings`"
msgstr ":ref:`f-strings`"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:362
msgid "String literals that have embedded expressions."
msgstr "内嵌表达式的字符串字面值。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:365
msgid ":ref:`formatstrings`"
msgstr ":ref:`formatstrings`"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:365
msgid "Information about string formatting with :meth:`str.format`."
msgstr "使用 :meth:`str.format` 进行字符串格式化。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:368
msgid ":ref:`old-string-formatting`"
msgstr ":ref:`old-string-formatting`"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:368
msgid ""
"The old formatting operations invoked when strings are the left operand of "
"the ``%`` operator are described in more detail here."
msgstr "这里详述了使用 ``%`` 运算符进行字符串格式化。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:375
msgid "Lists"
msgstr "列表"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:377
msgid ""
"Python knows a number of *compound* data types, used to group together other"
" values. The most versatile is the *list*, which can be written as a list "
"of comma-separated values (items) between square brackets. Lists might "
"contain items of different types, but usually the items all have the same "
"type. ::"
msgstr ""
"Python 中可以通过组合一些值得到多种 *复合* 数据类型。其中最常用的 *列表* ,可以通过方括号括起、逗号分隔的一组值(元素)得到。一个 "
"*列表* 可以包含不同类型的元素,但通常使用时各个元素类型相同::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:386
msgid ""
"Like strings (and all other built-in :term:`sequence` types), lists can be "
"indexed and sliced::"
msgstr "和字符串(以及各种内置的 :term:`sequence` 类型)一样,列表也支持索引和切片::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:396
msgid ""
"All slice operations return a new list containing the requested elements. "
"This means that the following slice returns a new (shallow) copy of the "
"list::"
msgstr "所有的切片操作都返回一个新列表,这个新列表包含所需要的元素。就是说,如下的切片会返回列表的一个新的(浅)拷贝::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:402
msgid "Lists also support operations like concatenation::"
msgstr "列表同样支持拼接操作::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:407
msgid ""
"Unlike strings, which are :term:`immutable`, lists are a :term:`mutable` "
"type, i.e. it is possible to change their content::"
msgstr "与 :term:`immutable` 的字符串不同, 列表是一个 :term:`mutable` 类型,就是说,它自己的内容可以改变::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:417
msgid ""
"You can also add new items at the end of the list, by using the "
":meth:`~list.append` *method* (we will see more about methods later)::"
msgstr "你也可以在列表末尾通过 :meth:`~list.append` *方法* 来添加新元素(我们将在后面介绍有关方法的详情)::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:425
msgid ""
"Assignment to slices is also possible, and this can even change the size of "
"the list or clear it entirely::"
msgstr "给切片赋值也是可以的,这样甚至可以改变列表大小,或者把列表整个清空::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:444
msgid "The built-in function :func:`len` also applies to lists::"
msgstr "内置函数 :func:`len` 也可以作用到列表上::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:450
msgid ""
"It is possible to nest lists (create lists containing other lists), for "
"example::"
msgstr "也可以嵌套列表 (创建包含其他列表的列表), 比如说::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:466
msgid "First Steps Towards Programming"
msgstr "走向编程的第一步"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:468
msgid ""
"Of course, we can use Python for more complicated tasks than adding two and "
"two together. For instance, we can write an initial sub-sequence of the "
"`Fibonacci series <https://en.wikipedia.org/wiki/Fibonacci_number>`_ as "
"follows::"
msgstr ""
"当然,我们可以将 Python 用于更复杂的任务,而不是仅仅两个和两个一起添加。 例如,我们可以编写 `斐波那契数列 "
"<https://en.wikipedia.org/wiki/Fibonacci_number>`_ 的初始子序列,如下所示::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:488
msgid "This example introduces several new features."
msgstr "这个例子引入了几个新的特性。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:490
msgid ""
"The first line contains a *multiple assignment*: the variables ``a`` and "
"``b`` simultaneously get the new values 0 and 1. On the last line this is "
"used again, demonstrating that the expressions on the right-hand side are "
"all evaluated first before any of the assignments take place. The right-"
"hand side expressions are evaluated from the left to the right."
msgstr ""
"第一行含有一个 *多重赋值*: 变量 ``a`` 和 ``b`` 同时得到了新值 0 和 1. 最后一行又用了一次多重赋值, "
"这展示出了右手边的表达式,在任何赋值发生之前就被求值了。右手边的表达式是从左到右被求值的。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:496
msgid ""
"The :keyword:`while` loop executes as long as the condition (here: ``a < "
"10``) remains true. In Python, like in C, any non-zero integer value is "
"true; zero is false. The condition may also be a string or list value, in "
"fact any sequence; anything with a non-zero length is true, empty sequences "
"are false. The test used in the example is a simple comparison. The "
"standard comparison operators are written the same as in C: ``<`` (less "
"than), ``>`` (greater than), ``==`` (equal to), ``<=`` (less than or equal "
"to), ``>=`` (greater than or equal to) and ``!=`` (not equal to)."
msgstr ""
":keyword:`while` 循环只要它的条件(这里指: ``a < 10``)保持为真就会一直执行。Python 和 C "
"一样,任何非零整数都为真;零为假。这个条件也可以是字符串或是列表的值,事实上任何序列都可以;长度非零就为真,空序列就为假。在这个例子里,判断条件是一个简单的比较。标准的比较操作符的写法和"
" C 语言里是一样: ``<`` (小于)、 ``>`` (大于)、 ``==`` (等于)、 ``<=`` (小于或等于)、 ``>=`` "
"(大于或等于)以及 ``!=`` (不等于)。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:505
msgid ""
"The *body* of the loop is *indented*: indentation is Python's way of "
"grouping statements. At the interactive prompt, you have to type a tab or "
"space(s) for each indented line. In practice you will prepare more "
"complicated input for Python with a text editor; all decent text editors "
"have an auto-indent facility. When a compound statement is entered "
"interactively, it must be followed by a blank line to indicate completion "
"(since the parser cannot guess when you have typed the last line). Note "
"that each line within a basic block must be indented by the same amount."
msgstr ""
"*循环体* 是 *缩进的* :缩进是 Python 组织语句的方式。在交互式命令行里,你得给每个缩进的行敲下 Tab "
"键或者(多个)空格键。实际上用文本编辑器的话,你要准备更复杂的输入方式;所有像样的文本编辑器都有自动缩进的设置。交互式命令行里,当一个组合的语句输入时,"
" 需要在最后敲一个空白行表示完成(因为语法分析器猜不出来你什么时候打的是最后一行)。注意,在同一块语句中的每一行,都要缩进相同的长度。"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:514
msgid ""
"The :func:`print` function writes the value of the argument(s) it is given. "
"It differs from just writing the expression you want to write (as we did "
"earlier in the calculator examples) in the way it handles multiple "
"arguments, floating point quantities, and strings. Strings are printed "
"without quotes, and a space is inserted between items, so you can format "
"things nicely, like this::"
msgstr ""
":func:`print` 函数将所有传进来的参数值打印出来. 它和直接输入你要显示的表达式(比如我们之前在计算器的例子里做的)不一样, print()"
" 能处理多个参数,包括浮点数,字符串。 字符串会打印不带引号的内容, 并且在参数项之间会插入一个空格, 这样你就可以很好的把东西格式化, 像这样::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:525
msgid ""
"The keyword argument *end* can be used to avoid the newline after the "
"output, or end the output with a different string::"
msgstr "关键字参数 *end* 可以用来取消输出后面的换行, 或使用另外一个字符串来结尾::"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:537
msgid "Footnotes"
msgstr "备注"
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:538
msgid ""
"Since ``**`` has higher precedence than ``-``, ``-3**2`` will be interpreted"
" as ``-(3**2)`` and thus result in ``-9``. To avoid this and get ``9``, you"
" can use ``(-3)**2``."
msgstr ""
"因为 ``**`` 比 ``-`` 有更高的优先级, 所以 ``-3**2`` 会被解释成 ``-(3**2)`` ,因此结果是 ``-9``. "
"为了避免这个并且得到结果 ``9``, 你可以用这个式子 ``(-3)**2``."
#: /home/runner/work/docspush-transifex/docspush-transifex/cpython/Doc/tutorial/introduction.rst:542
msgid ""
"Unlike other languages, special characters such as ``\\n`` have the same "
"meaning with both single (``'...'``) and double (``\"...\"``) quotes. The "
"only difference between the two is that within single quotes you don't need "
"to escape ``\"`` (but you have to escape ``\\'``) and vice versa."
msgstr ""
"和其他语言不一样的是, 特殊字符比如说 ``\\n`` 在单引号 (``'...'``) 和双引号 (``\"...\"``) 里有一样的意义. "
"这两种引号唯一的区别是,你不需要在单引号里转义双引号 ``\"`` (但是你必须把单引号转义成 ``\\'``) , 反之亦然."