Errno 2没有这样的文件或目录:'credentials.json'

时间:2019-11-27 18:54:39

标签: python-3.x

python 3.6

仍在学习python的过程中,使用公开来源的以下代码,但遇到了这个问题:

“ [Errno 2]没有这样的文件或目录:'credentials.json'” 文件“ C:\ Users \ BLINDEYE \ Desktop \ GeminiBots \ main.py”,

with open("credentials.json", "r") as f:
    credentials = json.loads(f.read())
CONSUMER_KEY = credentials['CONSUMER_KEY']
CONSUMER_SECRET = credentials['CONSUMER_SECRET']
ACCESS_TOKEN = credentials['ACCESS_TOKEN']
ACCESS_TOKEN_SECRET = credentials['ACCESS_TOKEN_SECRET']

不知道即时消息是否位于错误的目录中,或者是否将requests.json存储在其中 C:\ Users \ BLINDEYE \ Desktop \ GeminiBots

任何帮助将不胜感激

2 个答案:

答案 0 :(得分:1)

C:\ Users \ BLINDEYE \ Desktop \ GeminiBots \ credentials.json? 这是路径吗?您可以在上面尝试此绝对路径。

答案 1 :(得分:0)

我认为littlecute意味着尝试此操作:

 with open("C:/Users/BLINDEYE/Desktop/GeminiBots/credentials.json", "r") as f: