Skip to content

Commit 60286b8

Browse files
committed
Open
1 parent 0e9cbd3 commit 60286b8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,8 +1261,10 @@ Open
12611261
**Opens a file and returns a corresponding file object.**
12621262

12631263
```python
1264-
<file> = open('<path>', mode='r', encoding=None)
1264+
<file> = open('<path>', mode='r', encoding=None, endline=None)
12651265
```
1266+
* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `"encoding='utf-8'"` whenever possible.**
1267+
* **`'endline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
12661268

12671269
### Modes
12681270
* **`'r'` - Read (default).**

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,12 @@ <h3 id="argparse">Argparse</h3>
11411141
</ul>
11421142
<h2 id="open"><a href="#open" name="open">#</a>Open</h2>
11431143
<p><strong>Opens a file and returns a corresponding file object.</strong></p>
1144-
<pre><code class="python language-python hljs">&lt;file&gt; = open(<span class="hljs-string">'&lt;path&gt;'</span>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>)
1144+
<pre><code class="python language-python hljs">&lt;file&gt; = open(<span class="hljs-string">'&lt;path&gt;'</span>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, endline=<span class="hljs-keyword">None</span>)
11451145
</code></pre>
1146+
<ul>
1147+
<li><strong><code class="python hljs"><span class="hljs-string">'encoding=None'</span></code> means default encoding is used, which is platform dependent. Best practice is to use <code class="python hljs"><span class="hljs-string">"encoding='utf-8'"</span></code> whenever possible.</strong></li>
1148+
<li><strong><code class="python hljs"><span class="hljs-string">'endline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
1149+
</ul>
11461150
<h3 id="modes">Modes</h3>
11471151
<ul>
11481152
<li><strong><code class="python hljs"><span class="hljs-string">'r'</span></code> - Read (default).</strong></li>

0 commit comments

Comments
 (0)