liv*_*hak 6 python glob python-3.x
I have a list of csv files in mydir.I want to get the list of file names. however using glob as below is returning an empty list.
import glob
mydir = "C:\Data"
file_list = glob(mydir + "*.csv")
print('file_list {}'.format(file_list))
Run Code Online (Sandbox Code Playgroud)
Looks like you just need to include your slash to search in the correct directory.
import glob
mydir = "C:\Data"
file_list = glob.glob(mydir + "/*.csv") # Include slash or it will search in the wrong directory!!
print('file_list {}'.format(file_list))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14761 次 |
| 最近记录: |