Open file knowing only a part of its name

后端 未结 4 974
轻奢々
轻奢々 2021-01-05 04:52

I\'m currently reading a file and importing the data in it with the line:

# Read data from file.
data = np.loadtxt(join(mypath, \'file.data\'), unpack=True)
         


        
4条回答
  •  余生分开走
    2021-01-05 05:27

    Also check out fnmatch:

    >>> import fnmatch
    >>> import os
    >>>
    >>> fnmatch.filter(os.listdir('.'), 'file_*.data')
    ['file_3453453.data']
    >>>
    

提交回复
热议问题