Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 找不到扩展名。Cogs discord.py_Python_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python 找不到扩展名。Cogs discord.py

Python 找不到扩展名。Cogs discord.py,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,这是我的密码 for filename in os.listdir('lib\commands'): if filename.endswith('.py'): client.load_extension(f'cogs.{filename[:-3]}') 我的错误: Exception has occurred: ExtensionNotFound Extension 'cogs.ping_clear' could not be loaded. File "C:\Users

这是我的密码

for filename in os.listdir('lib\commands'):
if filename.endswith('.py'):
    client.load_extension(f'cogs.{filename[:-3]}')
我的错误:

Exception has occurred: ExtensionNotFound
Extension 'cogs.ping_clear' could not be loaded.
  File "C:\Users\sakch\Desktop\Bot\main.py", line 15, in <module>
    client.load_extension(f'cogs.{filename[:-3]}')
发生异常:ExtensionNotFound 无法加载扩展“cogs.ping_clear”。 文件“C:\Users\sakch\Desktop\Bot\main.py”,第15行,在 client.load_扩展名(f'cogs.{filename[:-3]}')

您在
加载扩展中放置了错误的路径。您应该传递与
os.listdir中相同的路径

os.listdir('lib\commands')中文件名的
:
如果filename.endswith('.py'):
client.load_扩展名(f'lib.commands.{filename[:-3]}')
Plase,提供一个。