python - FileNotFoundError: [Errno 2] No such file or directory: (using import OS)
问题描述
I looked around for solutions. One of them is to use os.path, but I still get an error. I'm trying to send an image to a discord server channel when the bot is up and running here is the documentation. But I get an error FileNotFoundError: [Errno 2] No such file or directory:
Attached are some screenshots of my project, code, & error message.
解决方案
路径似乎并不完整。dog.png 在 src 文件夹中,所以不要使用 is,只需自己指定目录BASE_DIR = '.\Pickle Rick BOT\src'。然后您可以使用 os.path.join 或 f 流的简单字符串连接将dog.png部分加入到此。反斜杠应该加倍。
推荐阅读
- php - MemCache 需要加载 PHP memcache 扩展
- javascript - 配置 reactjs 以将前端样式与管理样式分开
- jenkins - 带有 Jenkins 参数和声明性管道的分隔符
- fiware - FIWARE Orion Context Broker API V2 - accumulator-server.py
- ios - 为什么要在 iOS 中创建自定义通知广播中心
- c# - 在移动到另一列之前逐列扫描列和行 MULTIDIMENSIONAL ARRAY C#(UNITY)
- wix - JRE 安装条件无法正常工作
- c++ - LNK1181:无法打开输入文件 'release\main.obj' - 重建 QT 应用程序时
- javascript - 将动画重写为基于时间(不是基于平速)
- caching - 如何在redis缓存中存储整数值?