0

I want to read a bson file with utf-8 encoding but I don't know where to insert the encoding format.

here is my code:

with open('filename.bson','rb') as f:
    data = bson.decode_all(f.read())

2 Answers2

0

You can insert encoding within open function

with open('filename.bson','rb', encoding='utf-8') as f:
    data = bson.decode_all(f.read())
Ghanteyyy
  • 484
  • 1
  • 5
  • 12
0
import io

f = io.open('filename.bson', mode='rb', encoding='utf-8')