python处理NC文件时,常用的一些函数

一、glob.glob()

返回所有匹配的文件路径列表。

参数pathname,定义了文件路径匹配规则,可以是绝对路径,也可以是相对路径。

例如以下代码就会返回所有符合该规则的文件路径:

t2m_path_list = glob.glob('G:/aaa/sat_dir/mask_daily/era5_t2m_????????.tif')

可以通过循环遍历每一个文件:

for path in tif_path_list:
    print(path)

猜你喜欢

转载自blog.csdn.net/Mluoo/article/details/130921597