微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

命令提示说当文件存在时无法找到文件

如何解决命令提示说当文件存在时无法找到文件

所以我有一个我正在尝试运行的 .py 脚本,并且在命令提示符或 anaconda 提示符下。如果我运行 CURL *curl; std::string res; curl = curl_easy_init(); if(curl) { try { curl_easy_setopt(curl,CURLOPT_TCP_NODELAY,0); curl_easy_setopt(curl,CURLOPT_URL,"https://accounts.spotify.com/api/token"); curl_easy_setopt(curl,CURLOPT_POSTFIELDS,"grant_type=authorization_code&code=abcdef&redirect_uri=example.com"); curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,WriteCallback); curl_easy_setopt(curl,CURLOPT_WRITEDATA,&res); std::string enc = base64_encode(reinterpret_cast<const unsigned char*>((myClientID + ":" + myClientSecret).data()),(myclientID + ":" + myClientSecret).length(),false); std::string httpAuth = "Authorization: Basic " + enc; struct curl_slist *authChunk = nullptr; authChunk = curl_slist_append(authChunk,httpAuth.c_str()); curl_easy_setopt(curl,CURLOPT_HTTPHEADER,authChunk); curl_easy_perform(curl); curl_easy_cleanup(curl); } catch (const char* Exception) { std::cerr << Exception << std::endl; } } ,它会给我这个错误python filename.py

我不知道如何解决这个问题,因为文件在那个位置。我需要修改一些设置吗?

我使用 Visual Studio 2019 作为我的 Python IDE。

python: can't open file 'C:\Users\tform\Documents\Airsim\CapstoneAPI.py': [Errno 2] No such file or directory

解决方法

正如人们所说,当我们在终端中使用命令“python name.py”运行python脚本时,我们需要输入这个python文件的父文件夹才能找到它。

enter image description here

解决方案:我们可以使用“cd”去到python文件的父文件夹:(请去你的文件夹“AirSim”。)

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。