Skip to content

Commit f09069e

Browse files
committed
翻译一篇文章以及修正一个错误
1 parent b31085e commit f09069e

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

source/c13/p05_getting_terminal_size.rst

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,33 @@
55
----------
66
问题
77
----------
8-
You need to get the terminal size in order to properly format the output of your program.
8+
你需要知道当前终端的大小以便正确的格式化输出。
99

1010
|
1111
1212
----------
1313
解决方案
1414
----------
15-
Use the os.get_terminal_size() function to do this:
16-
17-
>>> import os
18-
>>> sz = os.get_terminal_size()
19-
>>> sz
20-
os.terminal_size(columns=80, lines=24)
21-
>>> sz.columns
22-
80
23-
>>> sz.lines
24-
24
25-
>>>
15+
使用 ``os.get_terminal_size()`` 函数来做到这一点。
16+
17+
代码示例:
18+
19+
.. code-block:: python
20+
21+
>>> import os
22+
>>> sz = os.get_terminal_size()
23+
>>> sz
24+
os.terminal_size(columns=80, lines=24)
25+
>>> sz.columns
26+
80
27+
>>> sz.lines
28+
24
29+
>>>
2630
2731
|
2832
2933
----------
3034
讨论
3135
----------
32-
There are many other possible approaches for obtaining the terminal size, ranging from
33-
reading environment variables to executing low-level system calls involving ioctl()
34-
and TTYs. Frankly, why would you bother with that when this one simple call will
35-
suffice?
36+
有太多方式来得知终端大小了,从读取环境变量到执行底层的 ``ioctl()`` 函数等等。
37+
不过,为什么要去研究这些复杂的办法而不是仅仅调用一个简单的函数呢?

source/c13/p10_read_configuration_files.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ True
5959
32
6060
>>> print(cfg.get('server','signature'))
6161

62-
=================================
62+
\=================================
6363
Brought to you by the Python Cookbook
64-
=================================
64+
\=================================
6565
>>>
6666

6767
If desired, you can also modify the configuration and write it back to a file using the

0 commit comments

Comments
 (0)