首页 > 解决方案 > VS Code 中的 Python genfromtxt 找不到 txt

问题描述

我正在尝试使用 Visual Code 读取与我的 python 执行目录位于同一文件夹中的 .txt 文件。但是,Visual Code 根本找不到该文件。我已经用命令 os.getcwd() 检查了我与 .txt 文件在同一目录中,但是,程序出现以下错误:

Exception has occurred: OSError
t43_2_rl1_str_Idvg_Vds_4_IV0.txt not found.
File "/home/User/Desktop/Directory/Trans/L_VT_I_CTE.py", line 5, in lecture
data = np.genfromtxt(name,dtype='float')

如果我打印os.getcws,我会得到:

/home/User/Desktop/Directory

那是同一个目录...我尝试更改launch.json,包括cwd,但是没有用...即使尝试在ubuntu终端中执行该文件,我也遇到了同样的错误...

我究竟做错了什么?

谢谢!!

标签: pythonnumpyvisual-studio-code

解决方案


我发现了我的错误......我只是添加了更改文件名"Trans/t43_2_rl1_str_Idvg_Vds_4_IV0.txt",它确实有效!

谢谢你=)


推荐阅读