Skip to content

Commit dfe8363

Browse files
Update 3 translated till 10.10
1 parent 4a7b7df commit dfe8363

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

10.-brief-tour-of-the-standard-library.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,21 @@ Có một số mô-đun để truy cập internet và xử lý các giao thức
155155

156156
\(Lưu ý rằng ví dụ thứ hai cần một máy chủ thư (mailserver) chạy trên máy chủ cục bộ (localhost).\)
157157

158-
### 10.8. Dates and Times
159158

160-
The [`datetime`](https://docs.python.org/3/library/datetime.html#module-datetime) module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic is supported, the focus of the implementation is on efficient member extraction for output formatting and manipulation. The module also supports objects that are timezone aware.>>>
159+
### 10.8. Ngày và giờ (Dates and Times)
160+
161+
Mô-đun [`datetime`] (https://docs.python.org/3/library/datetime.html#module-datetime) cung cấp các lớp (classes) để thao tác ngày tháng và thời gian theo cả hai cách đơn giản và phức tạp. Trong khi ngày giờ số học được hỗ trợ, trọng tâm của việc thực hiện (implementation) là trích xuất thành viên hiệu quả cho định dạng đầu ra và thao tác. Mô-đun này cũng hỗ trợ các đối tượng nhận biết múi giờ. >>>
161162

162163
```text
163-
>>> # dates are easily constructed and formatted
164+
>>> # ngày giờ được xây dựng và định dạng dễ dàng
164165
>>> from datetime import date
165166
>>> now = date.today()
166167
>>> now
167168
datetime.date(2003, 12, 2)
168169
>>> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
169170
'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'
170171
171-
>>> # dates support calendar arithmetic
172+
>>> # ngày hỗ trợ số học lịch (calender)
172173
>>> birthday = date(1964, 7, 31)
173174
>>> age = now - birthday
174175
>>> age.days
@@ -177,7 +178,7 @@ datetime.date(2003, 12, 2)
177178

178179
### 10.9. Data Compression
179180

180-
Common data archiving and compression formats are directly supported by modules including: [`zlib`](https://docs.python.org/3/library/zlib.html#module-zlib), [`gzip`](https://docs.python.org/3/library/gzip.html#module-gzip), [`bz2`](https://docs.python.org/3/library/bz2.html#module-bz2), [`lzma`](https://docs.python.org/3/library/lzma.html#module-lzma), [`zipfile`](https://docs.python.org/3/library/zipfile.html#module-zipfile) and [`tarfile`](https://docs.python.org/3/library/tarfile.html#module-tarfile).>>>
181+
Các định dạng nén và lưu trữ dữ liệu được hỗ trợ trực tiếp bởi các mô-đun bao gồm: [`zlib`](https://docs.python.org/3/library/zlib.html#module-zlib), [`gzip`](https://docs.python.org/3/library/gzip.html#module-gzip), [`bz2`](https://docs.python.org/3/library/bz2.html#module-bz2), [`lzma`](https://docs.python.org/3/library/lzma.html#module-lzma), [`zipfile`](https://docs.python.org/3/library/zipfile.html#module-zipfile) and [`tarfile`](https://docs.python.org/3/library/tarfile.html#module-tarfile).>>>
181182

182183
```text
183184
>>> import zlib
@@ -195,10 +196,12 @@ b'witch which has which witches wrist watch'
195196

196197
### 10.10. Performance Measurement
197198

198-
Some Python users develop a deep interest in knowing the relative performance of different approaches to the same problem. Python provides a measurement tool that answers those questions immediately.
199+
Một số người dùng Python phát triển một sự quan tâm sâu sắc trong việc biết hiệu suất tương đối của các cách tiếp cận khác nhau cho cùng một vấn đề. Python cung cấp một công cụ đo lường để trả lời các câu hỏi đó ngay lập tức.
199200

200201
For example, it may be tempting to use the tuple packing and unpacking feature instead of the traditional approach to swapping arguments. The [`timeit`](https://docs.python.org/3/library/timeit.html#module-timeit) module quickly demonstrates a modest performance advantage:>>>
201202

203+
Ví dụ, nó có thể hấp dẫn để sử dụng tính năng đóng gói và giải nén tuple thay vì cách tiếp cận truyền thống để hoán đổi đối số. Mô-đun [`timeit`](https://docs.python.org/3/library/timeit.html#module-timeit) chứng tỏ một cách nhanh chóng về lợi thế hiệu suất: > > >
204+
202205
```text
203206
>>> from timeit import Timer
204207
>>> Timer('t=a; a=b; b=t', 'a=1; b=2').timeit()
@@ -207,13 +210,14 @@ For example, it may be tempting to use the tuple packing and unpacking feature i
207210
0.54962537085770791
208211
```
209212

210-
In contrast to [`timeit`](https://docs.python.org/3/library/timeit.html#module-timeit)’s fine level of granularity, the [`profile`](https://docs.python.org/3/library/profile.html#module-profile) and [`pstats`](https://docs.python.org/3/library/profile.html#module-pstats) modules provide tools for identifying time critical sections in larger blocks of code.
213+
Ngược lại với mức độ chi tiết của [`timeit`](https://docs.python.org/3/library/timeit.html#module-timeit), các mô-đun [`profile`](https://docs.python.org/3/library/profile.html#module-profile) [`pstats`](https://docs.python.org/3/library/profile.html#module-pstats) cung cấp các công cụ cho việc xác định các phần thời gian quan trọng trong các khối mã (code) lớn hơn.
211214

212215
### 10.11. Quality Control
213216

214-
One approach for developing high quality software is to write tests for each function as it is developed and to run those tests frequently during the development process.
215217

216-
The [`doctest`](https://docs.python.org/3/library/doctest.html#module-doctest) module provides a tool for scanning a module and validating tests embedded in a program’s docstrings. Test construction is as simple as cutting-and-pasting a typical call along with its results into the docstring. This improves the documentation by providing the user with an example and it allows the doctest module to make sure the code remains true to the documentation:
218+
Một cách tiếp cận để phát triển phần mềm chất lượng cao là viết các bài kiểm thử (tests) cho từng chức năng khi nó được phát triển và chạy các bài kiểm thử đó thường xuyên trong quá trình phát triển.
219+
220+
Mô-đun [`doctest`](https://docs.python.org/3/library/doctest.html#module-doctest) cung cấp công cụ để quét mô-đun và xác thực các bài kiểm thử được nhúng trong tài liệu của chương trình. Việc xây dựng kiểm thử đơn giản như việc cắt và dán thông thường cùng với các kết quả của nó vào trong tài liệu (docstring). Điều này cải thiện tài liệu bằng cách cung cấp cho người dùng một ví dụ và nó cho phép mô-đun *doctest* đảm bảo mã (code) vẫn đúng với tài liệu:
217221

218222
```text
219223
def average(values):
@@ -228,7 +232,7 @@ import doctest
228232
doctest.testmod() # automatically validate the embedded tests
229233
```
230234

231-
The [`unittest`](https://docs.python.org/3/library/unittest.html#module-unittest) module is not as effortless as the [`doctest`](https://docs.python.org/3/library/doctest.html#module-doctest) module, but it allows a more comprehensive set of tests to be maintained in a separate file:
235+
Mô-đun [`unittest`](https://docs.python.org/3/library/unittest.html#module-unittest) không dễ dàng như mô-đun [`doctest`](https://docs.python.org/3/library/doctest.html#module-doctest), nhưng nó cho phép kiểm tra toàn diện hơn được duy trì trong một tệp riêng biệt:
232236

233237
```text
234238
import unittest
@@ -243,8 +247,7 @@ class TestStatisticalFunctions(unittest.TestCase):
243247
with self.assertRaises(TypeError):
244248
average(20, 30, 70)
245249
246-
unittest.main() # Calling from the command line invokes all tests
247-
```
250+
unittest.main() # Gọi từ dòng lệnh kích hoạt tất cả các trường hợp kiểm thử
248251
249252
### 10.12. Batteries Included
250253

0 commit comments

Comments
 (0)