python - 如何在我的 python 代码 (discord.py) 上写下 Github 导入文件夹的名称?
问题描述
我的 python bot 代码有问题,我需要 chdir 到我所有文件都在 Github 中的文件夹,但我不知道该怎么做。
我试过这个但它不起作用:
os.chdir("Game-Master /")
它在日志上给了我这个错误:
2020-11-17T20:29:12.491976+00:00 heroku[worker.1]: State changed from crashed to starting
2020-11-17T20:29:15.869590+00:00 heroku[worker.1]: Starting process with command `python main.py`
2020-11-17T20:29:16.520541+00:00 heroku[worker.1]: State changed from starting to up
2020-11-17T20:29:18.493338+00:00 app[worker.1]: Traceback (most recent call last):
2020-11-17T20:29:18.493358+00:00 app[worker.1]: File "main.py", line 8, in <module>
2020-11-17T20:29:18.493535+00:00 app[worker.1]: os.chdir("Game-Master /")
2020-11-17T20:29:18.493589+00:00 app[worker.1]: FileNotFoundError: [Errno 2] No such file or directory: 'Game-Master /'
这是代码的重要部分:
import os
import discord
from discord.ext import commands
import asyncio
import json
import random
os.chdir("Game-Master /")
bot = commands.Bot(command_prefix = "!", description = "organise des combats")
token = str(os.environ.get('BOT_TOKEN'))
bot.remove_command('help')
解决方案
该目录只是 . 所以我只需要写“。” 在 chdir 上
os.chdir('.')
就这些
推荐阅读
- c - 右位移将 1 添加到 C 中 unsigned int 的开头
- android - 如何重置计步器?
- python - 是否可以使用 python 在 sqlite3 中运行多个语句?
- javascript - '无法设置未定义的属性“innerHTML”' - 但它已定义
- vim - 根据模式匹配突出显示整行
- graph - GTFS 到图形的转换?
- sql-server - 如何让 SSIS 包动态选择所需的连接管理器?
- java - 是否可以使用通配符逻辑“*”通过 Apache Maven 目标和选项列出特定目录?
- visual-studio-code - VSCode 在打开某些文件时隐藏文件夹内容
- arrays - 读取文件文本的奇数行并添加到 bash 中的数组