且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将 .xlsx 导入 Python:没有这样的文件或目录

更新时间:2023-02-22 20:42:03

操作系统中的每个进程都有一个当前工作目录.任何相对路径都是相对于当前工作目录的.

Each process in the operating system has a current working directory. Any relative path is relative to the current working directory.

当前工作目录设置为您启动进程的目录.这在使用命令行时很自然,但对于只使用 GUI 的人来说会令人困惑.

The current working directory is set to the directory from which you launched the process. This is very natural when using the command-line, but get be confusing for people only using GUIs.

您可以使用 os.getcwd(),您可以使用 更改它os.chdir().当然,您也可以在启动脚本之前对其进行更改.

You can retrieve it using os.getcwd(), and you can change it using os.chdir(). Of course, you can also change it before launching your script.