python - 我不能在heroku上用python制作文件
问题描述
当我的代码中发生这种情况时,我的机器人会出错:
with open(f"tickets/{num}.txt","w+"):
之后它给出了这个错误:
Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/app/main.py", line 231, in on_reaction_add
with open(f"tickets/{num}.txt","w+") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'tickets/001.txt'
它适用于repli,但不适用于heroku。我该怎么办?
解决方案
检查tickets/
Heroku 机器上是否存在该目录。您可以通过在应用程序的仪表板上运行控制台来执行此操作。运行 bash,然后使用$ mkdir tickets
它来创建它。
推荐阅读
- sql - 为什么 $P!{} 在 JasperServer 上不能正常工作?
- vuejs2 - 如何为 VueJS Mixin 制作可重用的模板
- python - 如何使用 Plotly 为图形设置通用字体?
- java - 数组中第 K 个最大的元素 - LeetCode 问题
- python - 如何连接具有空白条件的某些列
- ruby-on-rails - 如何在 Rails 6 中使用自定义 jQuery
- assembly - 如何使用 PIC16F877A 比较一个值是否在多个范围之一内
- spring - Spring @Transactional 不适用于 InvocationHandler
- php - 为什么我尝试在 PHP 中执行 system(unzip) 后得到错误代码 50
- sql - 检查列上的索引