Skip to content

Commit a83e844

Browse files
Update 2 - translated 10.4-7
1 parent 0467808 commit a83e844

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,21 @@ Các tập lệnh (scripts) tiện ích phổ biến thường cần xử lý c
5757

5858
Mô-đun [`getopt`](https://docs.python.org/3/library/getopt.html#module-getopt) xử lý _sys.argv_ bằng cách sử dụng các quy ước của hàm [`getopt()`](https://docs.python.org/3/library/getopt.html#module-getopt)trên Unix. Xử lý dòng lệnh mạnh mẽ và linh hoạt hơn được cung cấp bởi mô-đun [`argparse`](https://docs.python.org/3/library/argparse.html#module-argparse).
5959

60-
### 10.4. Error Output Redirection and Program Termination
60+
### 10.4. Lỗi chuyển hướng đầu ra và kết thúc chương trình (Error Output Redirection and Program Termination)
61+
62+
Mô-đun [`sys`](https://docs.python.org/3/library/sys.html#module-sys) cũng có các thuộc tính cho _stdin_, _stdout_, and _stderr_. Cái sau cùng hữu ích khi phát ra các cảnh báo và thông báo lỗi để hiển thị chúng ngay cả khi _stdout_ đã được chuyển hướng:>>>
6163

62-
The [`sys`](https://docs.python.org/3/library/sys.html#module-sys) module also has attributes for _stdin_, _stdout_, and _stderr_. The latter is useful for emitting warnings and error messages to make them visible even when _stdout_ has been redirected:>>>
6364

6465
```text
6566
>>> sys.stderr.write('Warning, log file not found starting a new one\n')
6667
Warning, log file not found starting a new one
6768
```
6869

69-
The most direct way to terminate a script is to use `sys.exit()`.
70+
Cách trực tiếp nhất để chấm dứt tập lệnh là sử dụng `sys.exit()`.
7071

71-
### 10.5. String Pattern Matching
72+
### 10.5. So khớp mẫu chuỗi (String Pattern Matching)
7273

73-
The [`re`](https://docs.python.org/3/library/re.html#module-re) module provides regular expression tools for advanced string processing. For complex matching and manipulation, regular expressions offer succinct, optimized solutions:>>>
74+
Mô-đun [`re`](https://docs.python.org/3/library/re.html#module-re) cung cấp các công cụ biểu thức chính quy để xử lý chuỗi nâng cao. Để đối sánh và thao tác phức tạp, biểu thức chính quy cung cấp các giải pháp gọn gàng, được tối ưu hóa:>>>
7475

7576
```text
7677
>>> import re
@@ -80,27 +81,27 @@ The [`re`](https://docs.python.org/3/library/re.html#module-re) module provides
8081
'cat in the hat'
8182
```
8283

83-
When only simple capabilities are needed, string methods are preferred because they are easier to read and debug:>>>
84+
Khi chỉ có các khả năng đơn giản là cần thiết, các phương thức chuỗi được ưa thích vì chúng dễ đọc và gỡ lỗi hơn:>>>
8485

8586
```text
8687
>>> 'tea for too'.replace('too', 'two')
8788
'tea for two'
8889
```
8990

90-
### 10.6. Mathematics
91+
### 10.6. Toán học (Mathematics)
9192

9293
The [`math`](https://docs.python.org/3/library/math.html#module-math) module gives access to the underlying C library functions for floating point math:>>>
9394

95+
Mô-đun [`math`](https://docs.python.org/3/library/math.html#module-math) cho phép truy cập vào các hàm thư viện C bên dưới cho phép toán trên số thực (floating point math):>>>
96+
9497
```text
9598
>>> import math
9699
>>> math.cos(math.pi / 4)
97100
0.70710678118654757
98101
>>> math.log(1024, 2)
99102
10.0
100103
```
101-
102-
The [`random`](https://docs.python.org/3/library/random.html#module-random) module provides tools for making random selections:>>>
103-
104+
Mô-đun [`random`](https://docs.python.org/3/library/random.html#module-random) cung cấp các công cụ để thực hiện các lựa chọn ngẫu nhiên:>>>
104105
```text
105106
>>> import random
106107
>>> random.choice(['apple', 'pear', 'banana'])
@@ -113,8 +114,7 @@ The [`random`](https://docs.python.org/3/library/random.html#module-random) modu
113114
4
114115
```
115116

116-
The [`statistics`](https://docs.python.org/3/library/statistics.html#module-statistics) module calculates basic statistical properties \(the mean, median, variance, etc.\) of numeric data:>>>
117-
117+
Mô-đun [`statistics`](https://docs.python.org/3/library/statistics.html#module-statistics) tính toán các thuộc tính thông kê cơ bản \(the mean, median, variance, etc.\) của dữ liệu số:>>>
118118
```text
119119
>>> import statistics
120120
>>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]
@@ -126,11 +126,11 @@ The [`statistics`](https://docs.python.org/3/library/statistics.html#module-stat
126126
1.3720238095238095
127127
```
128128

129-
The SciPy project <[https://scipy.org](https://scipy.org/)> has many other modules for numerical computations.
130-
131-
### 10.7. Internet Access
129+
Dự án SciPy <[https://scipy.org](https://scipy.org/)> có nhiều mô-đun khác để tính toán số.
130+
131+
### 10.7. Truy cập Internet (Internet Access)
132132

133-
There are a number of modules for accessing the internet and processing internet protocols. Two of the simplest are [`urllib.request`](https://docs.python.org/3/library/urllib.request.html#module-urllib.request) for retrieving data from URLs and [`smtplib`](https://docs.python.org/3/library/smtplib.html#module-smtplib) for sending mail:>>>
133+
Có một số mô-đun để truy cập internet và xử lý các giao thức internet. Hai trong số mô-đun đơn giản nhất là [`urllib.request`](https://docs.python.org/3/library/urllib.request.html#module-urllib.request) để truy xuất dữ liệu từ các URLs [`smtplib`](https://docs.python.org/3/library/smtplib.html#module-smtplib) để gửi thư:>>>
134134

135135
```text
136136
>>> from urllib.request import urlopen
@@ -155,6 +155,8 @@ There are a number of modules for accessing the internet and processing internet
155155

156156
\(Note that the second example needs a mailserver running on localhost.\)
157157

158+
\(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).\)
159+
158160
### 10.8. Dates and Times
159161

160162
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.>>>

0 commit comments

Comments
 (0)