Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 181652f

Browse files
Translated Unit 10.1-3 - commit 20180521
1 parent 886bc72 commit 181652f

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
# 10. Brief Tour of the Standard Library
1+
# 10. Giới thiệu sơ lược về Thư viện chuẩn
22

33

4+
### 10.1. Giao diện hệ điều hành
45

5-
### 10.1. Operating System Interface
6-
7-
The [`os`](https://docs.python.org/3/library/os.html#module-os) module provides dozens of functions for interacting with the operating system:>>>
8-
6+
Mô-đun [`os`](https://docs.python.org/3/library/os.html#module-os) (os là viết tắt của operating system) cung cấp hàng tá chức năng để tương tác với hệ điều hành:
97
```text
108
>>> import os
11-
>>> os.getcwd() # Return the current working directory
9+
>>> os.getcwd() # Quay về thư mục làm việc hiện tại
1210
'C:\\Python36'
13-
>>> os.chdir('/server/accesslogs') # Change current working directory
14-
>>> os.system('mkdir today') # Run the command mkdir in the system shell
11+
>>> os.chdir('/server/accesslogs') # Thay đổi thư mục làm việc hiện tại
12+
>>> os.system('mkdir today') # Chạy lệnh mkdir trong thông dịch dòng lệnh hệ thống (the system shell)
1513
0
1614
```
1715

18-
Be sure to use the `import os` style instead of `from os import *`. This will keep [`os.open()`](https://docs.python.org/3/library/os.html#os.open) from shadowing the built-in [`open()`](https://docs.python.org/3/library/functions.html#open) function which operates much differently.
16+
Hãy dùng `import os` thay vì `from os import *`. Điều này giữ cho [`os.open()`](https://docs.python.org/3/library/os.html#os.open) khỏi việc che mờ hàm được dựng sẵn [`open()`](https://docs.python.org/3/library/functions.html#open) khiến các hoạt động sai khác đáng kể.
1917

20-
The built-in [`dir()`](https://docs.python.org/3/library/functions.html#dir) and [`help()`](https://docs.python.org/3/library/functions.html#help) functions are useful as interactive aids for working with large modules like [`os`](https://docs.python.org/3/library/os.html#module-os):>>>
18+
Các hàm dựng sẵn [`dir()`](https://docs.python.org/3/library/functions.html#dir) [`help()`](https://docs.python.org/3/library/functions.html#help) hữu ích giống như những hỗ trợ tương tác để làm việc với các mô đun (modules) lớn như [`os`](https://docs.python.org/3/library/os.html#module-os):
2119

2220
```text
2321
>>> import os
@@ -26,8 +24,7 @@ The built-in [`dir()`](https://docs.python.org/3/library/functions.html#dir) and
2624
>>> help(os)
2725
<returns an extensive manual page created from the module's docstrings>
2826
```
29-
30-
For daily file and directory management tasks, the [`shutil`](https://docs.python.org/3/library/shutil.html#module-shutil) module provides a higher level interface that is easier to use:&gt;&gt;&gt;
27+
Đối với các tác vụ quản lý thư mục và tệp hàng ngày, mô-đun [`shutil`](https://docs.python.org/3/library/shutil.html#module-shutil) cung cấp giao diện cấp cao hơn dễ sử dụng hơn:
3128

3229
```text
3330
>>> import shutil
@@ -37,27 +34,28 @@ For daily file and directory management tasks, the [`shutil`](https://docs.pytho
3734
'installdir'
3835
```
3936

40-
### 10.2. File Wildcards
37+
### 10.2. Tệp ký tự đại diện (File Wildcards)
38+
4139

42-
The [`glob`](https://docs.python.org/3/library/glob.html#module-glob) module provides a function for making file lists from directory wildcard searches:&gt;&gt;&gt;
40+
Mô-đun [`glob`](https://docs.python.org/3/library/glob.html#module-glob) cung cấp một hàm để tạo danh sách tệp từ các tìm kiếm theo ký tự đại diện:
4341

4442
```text
4543
>>> import glob
4644
>>> glob.glob('*.py')
4745
['primes.py', 'random.py', 'quote.py']
4846
```
4947

50-
### 10.3. Command Line Arguments
48+
### 10.3. Đối số dòng lệnh (Command Line Arguments)
5149

52-
Common utility scripts often need to process command line arguments. These arguments are stored in the [`sys`](https://docs.python.org/3/library/sys.html#module-sys)module’s _argv_ attribute as a list. For instance the following output results from running `python demo.py one twothree` at the command line:&gt;&gt;&gt;
50+
Các tập lệnh (scripts) tiện ích phổ biến thường cần xử lý các đối số dòng lệnh. Các đối số này được lưu trữ trong thuộc tính *argv* của mô-đun (module) [`sys`](https://docs.python.org/3/library/sys.html#module-sys) dưới dạng danh sách. Ví dụ kết quả đầu ra sau đây từ chạy `python demo.py one two three` tại dòng lệnh:
5351

5452
```text
5553
>>> import sys
5654
>>> print(sys.argv)
5755
['demo.py', 'one', 'two', 'three']
5856
```
5957

60-
The [`getopt`](https://docs.python.org/3/library/getopt.html#module-getopt) module processes _sys.argv_ using the conventions of the Unix [`getopt()`](https://docs.python.org/3/library/getopt.html#module-getopt) function. More powerful and flexible command line processing is provided by the [`argparse`](https://docs.python.org/3/library/argparse.html#module-argparse) module.
58+
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).
6159

6260
### 10.4. Error Output Redirection and Program Termination
6361

0 commit comments

Comments
 (0)