簡體   English   中英

AttributeError("'set' object 沒有屬性 'decode'

[英]AttributeError("'set' object has no attribute 'decode'

這是代碼:

message = "fancy message here that needs utf encoding".encode('utf-8')
await channel.send({messages}.decode('utf-8'))

然后我得到錯誤:

exception=AttributeError("'set' object has no attribute 'decode'")

如果我嘗試在頻道中刪除解碼 utf-8進步!

當您使用花括號時,您將編碼的消息插入到集合中,並且集合必須解碼屬性,如錯誤所述。 要在發送字符串時對其進行解碼,您可以執行以下操作:

channel.send(f"{messages.decode('utf-8')}")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM