【发布时间】:2021-12-30 03:59:51
【问题描述】:
我正在尝试向我的机器人添加日志记录功能
我试图让程序输出文本,但它输出的是对象引用
@bot.event
async def on_message(message: str):
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
with open("logs.txt", "a") as text_file:
print(f"<{st}> {message}", file=text_file)
我期待这样的事情 如果消息是“你好”在 2019-06-08 17:32 它会输出
<2019-06-08 17:32:26> hello
但确实如此
<2019-06-08 17:24:26> <discord.message.Message object at 0x0083C0A8>
【问题讨论】:
-
好吧,
message显然不是str对象 ;)
标签: python discord discord.py