遍历包含“.txt”文件的文件夹的文件显示错误

问题描述

我有一个包含一组 txt 文件文件夹。我想使用以下代码遍历所有这些:

import os
    import numpy as np
    # import matplotlib.pyplot as plt
    
    
    Folder = 'D:\\All Data\\Amr\\19-20-05-2021\\Probe - OPO\\Setup Spectrum\\Setup spectrum - spectrometer'
    
    for file in os.listdir(Folder):
        if file.endswith(".txt"):
            lam,Int = np.genfromtxt(file,skip_header=1,unpack = True)
            continue 
        else: 
            continue

文件夹如下所示:

enter image description here


不幸的是,上面的代码导致了以下错误
raise IOError("%s not found." % path)
OSError: lam600.txt not found.

我还想分别绘制每个 txt 文件。谁能告诉我我在这个脚本中做错了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)