сам код:
photo = open("forest_chill.jpg", encoding="cp1251")
async def main():
await client.send_file("me", photo, caption="Ку, как ты?")
with client:
client.loop.run_until_complete(main())
ошибка:
Traceback (most recent call last):
File "c:\Python Scripts\РАССЫЛКА TELEGA\test_4.py", line 19, in <module>
client.loop.run_until_complete(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "c:\Python Scripts\РАССЫЛКА TELEGA\test_4.py", line 16, in main
await client.send_file("me", photo, caption="Ку, как ты?")
File "C:\Users\liror\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\telethon\client\uploads.py", line 408, in send_file
file_handle, media, image = await self._file_to_media(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\liror\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\telethon\client\uploads.py", line 744, in _file_to_media
file_handle = await self.upload_file(
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\liror\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\telethon\client\uploads.py", line 643, in upload_file
part = await helpers._maybe_await(stream.read(part_size))
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\liror\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\telethon\helpers.py", line 402, in read
def read(self, *args, **kwargs): return self._stream.read(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1251.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 814: character maps to <undefined>