Skip to content

Commit 0bc2bc7

Browse files
authored
Update p09_add_directories_to_sys_path.rst
第51行, 应该是'但', 不应该是'它'
1 parent e83f233 commit 0bc2bc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/c10/p09_add_directories_to_sys_path.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
sys.path.insert(0, '/some/dir')
4949
sys.path.insert(0, '/other/dir')
5050
51-
虽然这能“工作”,它是在实践中极为脆弱,应尽量避免使用。这种方法的问题是,它将目录名硬编码到了你的源代码。如果你的代码被移到一个新的位置,这会导致维护问题。更好的做法是在不修改源代码的情况下,将path配置到其他地方。如果您使用模块级的变量来精心构造一个适当的绝对路径,有时你可以解决硬编码目录的问题,比如__file__。举个例子:
51+
虽然这能“工作”,但是在实践中极为脆弱,应尽量避免使用。这种方法的问题是,它将目录名硬编码到了你的源代码。如果你的代码被移到一个新的位置,这会导致维护问题。更好的做法是在不修改源代码的情况下,将path配置到其他地方。如果您使用模块级的变量来精心构造一个适当的绝对路径,有时你可以解决硬编码目录的问题,比如__file__。举个例子:
5252
5353
.. code-block:: python
5454

0 commit comments

Comments
 (0)