我无法在 heroku 上使用 python 创建文件
I cant make file with python on heroku
当我的代码中发生这种情况时,我的机器人会报错:
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'
它适用于 replit 但不适用于 heroku。我该怎么办?
检查 Heroku 机器上是否存在目录 tickets/
。您可以通过 运行 应用程序仪表板上的控制台来执行此操作。 运行bash,然后用$ mkdir tickets
创建。
当我的代码中发生这种情况时,我的机器人会报错:
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'
它适用于 replit 但不适用于 heroku。我该怎么办?
检查 Heroku 机器上是否存在目录 tickets/
。您可以通过 运行 应用程序仪表板上的控制台来执行此操作。 运行bash,然后用$ mkdir tickets
创建。