方法getUserPhotosRequest for file_reference

问题描述

我尝试获取file_file_reference,但无法解码结果

with TelegramClient('anon',api_id,api_hash) as client:
        result = client(functions.photos.GetUserPhotosRequest(
            user_id='******',offset=0,max_id=0,limit=0
        ))

        array_of_photos = result.photos
        for photo in array_of_photos:
            usert_photo = photo.file_reference
            print(usert_photo.decode('utf-8'))

结果:

b'\x00_F\x1a:\xc6\x1e\x9e\xc0\xd9\x18\x95\xff\x02\x01r\xff8d\xf2\xb9'
b"\x00_F\x18\xb6\xd51\xba\x1ek\x17\x0c\xc6I\x15\x96\xb4\x89\xb3\xa6'"
b'\x00_F\x18\xa6\xc0\xf72*FN\xe0|\x11\x9f+M\xfe\xe8Ab'

错误

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 7: invalid start byte

解决方法

该引用不能解码为字符串,而应存储为字节。