gpt4 book ai didi

python - Discord.py 重写 Cogs : Load extensions from other archive

转载 作者:行者123 更新时间:2023-12-01 09:00:49 28 4
gpt4 key购买 nike

当我尝试加载位于模块文件夹中的配置扩展时,我这样做,但它不起作用:

bot.load_extension("modules/config")

当我将其移动到主 python 文件所在的同一文件夹中时,它可以工作:

bot.load_extension("config")

那么如何从模块文件夹中加载它呢?

最佳答案

根据load_extension文档:

name (str) – The extension name to load. It must be dot separated like regular Python imports if accessing a sub-module. e.g. foo.test if you want to import foo/test.py.

所以您正在寻找 bot.load_extension("modules.config")

关于python - Discord.py 重写 Cogs : Load extensions from other archive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52464966/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com