vs code 运行switch,提示OSError: Cannot find file 'inputs\periods.csv'该怎么办(语言-python)

vs code运行switch,开始报错FileNotFoundError: [Errno 2] No such file or directory: 'inputs\periods.csv'

img

输入路径

img


之后又提示OSError: Cannot find file 'inputs\periods.csv'

img

该怎么办呀,求指点😭快崩溃了

1、使用绝对路径
2、在你使用的vscode命令行段,cd 进入inputs所在的目录里面。
因为vscode运行的时候,默认的目录不是你py所在的目录,所以你使用相对路径是不行的。

找不到这个文件'inputs\periods.csv'。确定一下路径

使用 OS 模块,获取绝对位置