Код: Выделить всё
import os
import bson
from bson.codec_options import CodecOptions
bson_codec_options = CodecOptions(
datetime_conversion='DATETIME_AUTO',
tz_aware=True,
unicode_decode_error_handler='ignore'
)
if __name__ == '__main__':
current_dir = os.getcwd()
bson_files = []
for file in os.listdir(current_dir):
current_item = os.path.join(current_dir, file)
if os.path.isfile(current_item) and file.endswith(".bson"):
bson_files.append(file)
for file in bson_files:
with open(os.path.join(current_dir, file), 'rb') as fcache:
data = bson.decode(fcache.read(), codec_options=bson_codec_options)
print(data)
File "C:\PyProjects\zulip.venv\Lib\site-packages\bson_init_ .py", строка 1094, в декодировании
return cast("Union[dict[str, Any], _DocumentType]", _bson_to_dict(data, opts))
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: объект 'str' не может быть интерпретирован как целое число
Надеюсь, кто-нибудь уже сталкивался с такой ошибкой, что вы делали?
Подробнее здесь: https://stackoverflow.com/questions/792 ... ot-working