TencentCloud / tencentcloud-sdk-python

Tencent Cloud API 3.0 SDK for Python
Apache License 2.0
613 stars 251 forks source link

a bytes-like object is required, not 'str' #60

Closed rexana3 closed 4 years ago

rexana3 commented 4 years ago
data = str(fwave.read())
dataLen = len(data)
base64Wav = base64.b64encode(data)

File "C:\Users\czy\Anaconda3\lib\base64.py", line 58, in b64encode encoded = binascii.b2a_base64(s, newline=False) TypeError: a bytes-like object is required, not 'str'

moyemoji commented 4 years ago

+1

rexana3 commented 4 years ago

Thank you for your relpy!Can you speak chinese?I put my code in the attachment.

------------------ 原始邮件 ------------------ 发件人: "moyemoji"<notifications@github.com>; 发送时间: 2020年4月11日(星期六) 下午5:55 收件人: "TencentCloud/tencentcloud-sdk-python"<tencentcloud-sdk-python@noreply.github.com>; 抄送: "陈柔洁"<497014168@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [TencentCloud/tencentcloud-sdk-python] a bytes-like object is required, not 'str' (#60)

+1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

zqfan commented 4 years ago

@rexana3 python3 base64.b64encode requires a byte input rather than a string, which means you don't need str(fwave.read()), just fwave.read() should work