擅长:python、mysql、java
<p><a href="https://www.python.org/dev/peps/pep-0008/" rel="nofollow">PEP-8</a>实际上给出了两种类似情况的示例:</p>
<p>示例1(看起来最适用,因为它使用了<code>with</code>语句):</p>
<pre><code>with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())
</code></pre>
<p>例2:</p>
<pre><code>class Rectangle(Blob):
def __init__(self, width, height,
color='black', emphasis=None, highlight=0):
</code></pre>
<p>看起来,斜杠是一种允许的处理方法(但如果将文件参数括在括号中,则最终是不必要的)。你知道吗</p>