vscode python代码在debug模式下找不到相对路径的文件

问题

在run的时候可以找到相对路径文件,而在debug模式下无法找到

FileNotFoundError: [Errno 2] No such file or directory: 'decode.js'

vscode python代码在debug模式下找不到相对路径的文件_第1张图片

解决办法

增加代码,解决问题

import os,sys
os.chdir(sys.path[0]) #使用文件所在目录

debug前进入代码相应文件夹

PS Z:\yrf\tencent\影视剧搜索-腾讯> cd .\douban\

你可能感兴趣的:(python,vscode,debug)