File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -83,22 +83,20 @@ Write BSON to a File
8383
8484To write BSON data to a file, open a file stream in write-binary mode on the output file.
8585Then, write each document to the output file. Ensure that documents are encoded in BSON
86- format by using the ``BSON .encode()`` method.
86+ format by using the ``bson .encode()`` method.
8787
8888The following example writes the sample BSON document to ``file.bson``:
8989
9090.. code-block:: python
9191
92- import bson
93-
9492 with open("file.bson", "w") as file:
95- file.write(BSON .encode(document))
93+ file.write(bson .encode(document))
9694
9795Read BSON from a File
9896---------------------
9997
10098To read BSON documents from a file, open a file stream in read-binary mode on the input
101- file. Then, decode the documents from BSON format as you read them by using the ``BSON .decode()``
99+ file. Then, decode the documents from BSON format as you read them by using the ``bson .decode()``
102100method.
103101
104102The following example reads the sample BSON document from ``file.bson``:
@@ -111,7 +109,7 @@ The following example reads the sample BSON document from ``file.bson``:
111109
112110 with open("file.bson", "rb") as file:
113111 data = file.read()
114- document = BSON(data) .decode()
112+ document = bson .decode(data )
115113 print(document)
116114
117115 .. output::
You can’t perform that action at this time.
0 commit comments